Anchors tie an expression to something else. Such as the begining or end of a line
Metacharacter | Description |
^ | Anchors to the begining of a line. A caret by itself indicates a line begining which all lines have. |
$ | Dollar anchors to the end of a line. |
Examples:
^Start
will display all lines that begin with S
followed by t
followed by a
followed by r
followed by t
regardless of what else is on the line. For example: will all be displayed with ^Start
- Start today
- Start living
- Start the car
end$
will display all lines that have e
followed by n
followed by d
just before the end of the line. Regardless what else is on the line. will all be displayed with end$
- This is the end
- We are near the end
- Rear end
- Bookend
^line$
will display all lines that begin with l
followed by i
followed by n
followed by e
followed by an end of line. For example this regex ^line$
will not display it will only display the single word line on a line by itself.
- New line
- Biline
- This is the end of the line
- Don not cross the line