| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Regular expressions 3. Anchors</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 3. Anchors |
| 13 | </b></font></table></table> |
| 14 | <p>Anchors let you specify a very specific position within the search text.</p> |
| 15 | <dl> |
| 16 | <dt><b>^</b> Try to match the (following) regex at the beginning of the string. |
| 17 | <dd> Example: "^ab" matches "ab" only at the beginning of a line and not, for example, in the line "cab".</dd> |
| 18 | <dt><b>$</b> Try to match the (following) regex at the end of the string. |
| 19 | <dt><b><</b> Try to match the regex at the <i>start</i> of a word. |
| 20 | <dd>The character class that defines a <i>word</i> can be found at the <a href="Regular_expressions_6__Convenience_escape_sequences.html">convenience escape sequences</a> page.</dd> |
| 21 | <dt><b>></b> Try to match the regex at the <i>end</i> of a word. |
| 22 | <dt><b>\B</b> Not a word boundary |
| 23 | </dl> |
| 24 | <h3>Links to this page</h3> |
| 25 | <ul> |
| 26 | <li><a href="Regular_expressions.html">Regular expressions</a> |
| 27 | <li><a href="Regular_expressions_1__Special_characters.html">Regular expressions 1. Special characters</a> |
| 28 | </ul> |
| 29 | <hr> |
| 30 | <address> |
| 31 | <p>© DAvid Weenink & Paul Boersma 20180401</p> |
| 32 | </address> |
| 33 | </body> |
| 34 | </html> |