LPM: Lookahead assertions

Matt Cashner eek at eekeek.org
Fri Apr 27 07:28:28 CDT 2001


On 27 Apr 2001, Rich Bowen wrote:

> Can someone adequately explain to me the lookahead assertion in regex? If that
> is indeed what they are called - the ?: notation on the beginning of a regex.

?: is not lookahead. note man perlre line 491

This is for clustering, not capturing; it groups
                 subexpressions like "()", but doesn't make back-
                 references as "()" does.

if you group something like /(?:foo|bar)/ you can form a group without
saving anything into $1, $2, etc.

zerowidth positive lookahed is (?=pattern)
zerowidth negative lookahead is (?!pattern)
lookbehinds use ?< with = and !

that make sense?

--------
Matt Cashner
Web Applications Developer
The Creative Group (http://www.cre8tivegroup.com)
eek at eekeek.org | Codito, ergo sum





More information about the Lexington-pm mailing list