This is a page from Aba Search and Replace help file.
- Welcome to Aba
- Getting started
- How-to guides
- Selecting the files to search in
- Inserting some text at the beginning of each file
- Replacing multiple lines of text
- Searching in Unicode files
- Replacing in binary files
- Performing operations with found files
- Undoing the replacement
- Saving search parameters for further use
- Removing private data
- Adding or removing Aba from Explorer context menu
- Integrating Aba with Total Commander
- Regular Expressions
- User interface
- Version history
Backreferences match the previously captured subexpression. Subexpressions are marked with parentheses and numbered from 1 to 9. Use
\1 to refer to the leftmost subexpression,
\2 to refer to the second subexpression, and so on.
||Find two equal numbers with space between them (e.g.,
||Find repeating words (e.g.,
||An external link (in single or double quotes)|
Sometimes you don't want to capture a subexpression, but only to group a part of your regex with parentheses. In this case, you can use a non-capturing group. Type
(?: ) instead of the usual parentheses.
||Find http:// or ftp:// URL|
||Ditto (without capturing “http or ftp”)|
If you don't have any references to the “http or ftp” subexpression, then the second example (with non-capturing group) is more appropriate. You will be unable to refer to the subexpression by using
\1, because the subexpression will not be saved.
Capturing and non-capturing groups can be mixed in a regex:
|Search for||Replace to||Explanation|
||Find an URL and remove the protocol from it|
Backreferences refer only to the usual, capturing parentheses; non-capturing groups are skipped from numeration. So,
\1 refers to
([^" >]+), not to
Non-capturing groups are useful in complex regular expressions, because the number of subexpressions is limited to 9 (from
\9), so you may want to capture only what is needed.
||Find “abc” repeating one or more times|
In this example, it makes no sense to capture the subexpression, because it's always equal to “abc”. So, the non-capturing group is a better choice here.