Aba logo

This is a page from Aba Search and Replace help file.

Replacement syntax

Sometimes you need to extract a part of the matching text and insert it in your replacement text. A typical example is displaying external links in a different color:

Search forReplace toExplanation
<a href="(http://[^"]+)"> <a href="\1" class="external-link"> Highlighting external links

The parentheses “captures” the subexpression, and \1 inserts it into your replacement text. \1 is the text inside the first parenthesis, \2 is the second one, and so on. \0 means the whole matching text. More examples:

Search forReplace toExplanation
http://[a-zA-Z0-9./_&=%?~#-]+ <a href="\0">\0</a> Make plain-text links clickable, i.e. put them into <A> tags
(\d\d?)/(\d\d?)/(\d\d\d\d) \2.\1.\3 Convert the American date format (4/25/2010) to the German format (25.4.2010)
\<(\w+) \1\> \1 Remove repeating words (the the will be replaced to a single the)

If you don't want parentheses to capture the subexpression, use a non-capturing group.

To insert a literal backslash character in your replacement text, repeat it twice: \\ instead of \.