34,333
edits
Changes
→Matching by Text Position
The final area of regular expressions to cover in this chapter involves matching based on the location of text in a string. For example, we may want to find a particular match that requires that a word appears at the beginning or end of a piece of text. Once again, this requires the use of some special metacharacters:
<table border="1" cellspacing="0">
<tr style="background:#efefef;">
<th>Metacharacter<th>Description</th>
<tr>
<td>^<td>Beginning of text</td>
<tr>
<td>$<td>End of text</td>
<tr>
<td>[[:<:]]<td>Start of word</td>
<tr>
<td>[[:<:]]<td>End of word</td>
</table>