Regexp Search and Remplace
Answers to Questions
What is a regular expression replacement?
It is a search and replace operation, but using a search by regular expression (or rational expression or regexp) that makes it possible to extract subsets of strings respecting a precise description. Regular expression replacements allow the ability of this search to be coupled with replacement capabilities based on the results of the search.
Example: ([a-z])[a-z] describes a set of any 2 consecutive letters. Replacing with $1 makes it possible to retain only the first letter.
What is a back-reference?
Parentheses are used to number and reference their contents. Each captured parenthesis encountered will thus be associated with a back reference.
A back reference is therefore a reference to a capturing submask defined previously (in parentheses).
The reference is noted with a backslash or with a dollar followed by a number greater than 0 and often limited to 9 or 99).
Example: The regex ((A)BC) will capture ABC in \1 and A in \2.