An Introduction to Regular Expressions Matching Rules 44 of 50 : [PREV] [NEXT]

Rule 4

If an assertion does not match according to the following table, the Engine backtracks to Rule 3 and tries a higher-pecking-order item with different choices.

^ Matches at the beginning of the string.
$ Matches at the end of the string.
\b Matches a word boundary (between \w and \W), when not inside [].
\B Matches a non-word boundary.

Note that Perl supports several other assertions, such as \A and \Z, which match the beginning and end of a string, respectively.

The $ assertion can match at the end of the string, or one character earlier than that, if the last character of the string is a new-line.


© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/