Debian Codegraph @

docs/manual/Regular_expressions_8__Substitution_special_characters.html

raw symbols SCIP
1 <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2 <title>Regular expressions 8. Substitution special characters</title>
3 <style>
4 td { padding-left: 5pt; padding-right: 5pt; }
5 th { padding-left: 5pt; padding-right: 5pt; }
6 code { white-space: pre-wrap; }
7 dd { white-space: pre-wrap; }
8 </style>
9 </head><body bgcolor="#FFFFFF">
10
11 <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b>
12 Regular expressions 8. Substitution special characters
13 </b></font></table></table>
14 <p>The substitution string is mostly interpreted as ordinary text except for the <a href="Regular_expressions_5__Special_control_characters.html">special control characters</a>, the <a href="Regular_expressions_7__Octal_and_hexadecimal_escapes.html">octal and hexadecimal escapes</a> and the following character combinations:</p>
15 <dl>
16 <dt><b></b>\1 ... <b></b>\9 are backreferences at sub-expressions 1 ... 9 in the match.
17 <dd>Any of the first nine sub-expressions of the match string can be inserted into the replacement string by inserting a &#8220;\&#8221; followed by a digit from 1 to 9 that represents the string matched by a parenthesized expression within the regular expression. The numbering is left to right.</dd>
18 <dd>&nbsp;&nbsp;&nbsp;Example: A search for "(a)(b)" in the string "abc", followed by a replace "\2\1" results in "bac".</dd>
19 <dt><b></b>&amp; reference at entire match.
20 <dd>The entire string that was matched by the search operation will be substituted.</dd>
21 <dd>&nbsp;&nbsp;&nbsp;Example: a search for "." in the string "abcd" followed by the replace "&amp;&amp;" doubles every character in the result "aabbccdd".</dd>
22 <dt><b></b>\U <b></b>\u to uppercase.
23 <dd>The text inserted by "&amp;" or "\1" ... "\9" is converted to <i>uppercase</i> ("\u" only changes the <i>first</i> character to uppercase).</dd>
24 <dd>&nbsp;&nbsp;&nbsp;Example: A search for "(aa)" in the string "aabb", followed by a replace "\U\1bc" results in the string "AAbcbb".</dd>
25 <dt><b></b>\L <b></b>\l to lowercase.
26 <dd>The text inserted by "&amp;" or "\1" ... "\9" is converted to <i>lowercase</i> ("\l" only changes the <i>first</i> character to lowercase).</dd>
27 <dd>&nbsp;&nbsp;&nbsp;Example: A search for "(AA)" with a replace "\l\1bc" in the string "AAbb" results in the string "aAbcbb".</dd>
28 </dl>
29 <h3>Links to this page</h3>
30 <ul>
31 <li><a href="Regular_expressions.html">Regular expressions</a>
32 <li><a href="Regular_expressions_1__Special_characters.html">Regular expressions 1. Special characters</a>
33 </ul>
34 <hr>
35 <address>
36 <p>© djmw 20010708</p>
37 </address>
38 </body>
39 </html>