[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
13.2.16 Lookahead
Positive lookahead (?=
) peeks ahead to ensure that
its subpattern could match.
(pregexp-match-positions "grey(?=hound)" "i left my grey socks at the greyhound") ⇒ ((28 . 32))
The regexp "grey(?=hound)"
matches grey
, but
only if it is followed by hound
. Thus, the first
grey
in the text string is not matched.
Negative lookahead (?!
) peeks ahead
to ensure that its subpattern could not possibly match.
(pregexp-match-positions "grey(?!hound)" "the gray greyhound ate the grey socks") ⇒ ((27 . 31))
The regexp "grey(?!hound)"
matches grey
, but
only if it is not followed by hound
. Thus
the grey
just before socks
is matched.
This document was generated on March 31, 2014 using texi2html 5.0.