Next | Regular Expression Mastery | 90 |
(?=...) and (?!...) are similar to \b and \B.
They look ahead in the string to see if what follows matches ...
If so, they succeed, but don't advance the cursor
Example: Match everything from <= up to next =>
Wrong: <=.*=>
(Consider <=foo bar => baz =>)
Solution:
/<=((?!=>).)*)=>/
Here's a trick: Make a pattern that never matches:
/(?!)/
Next | Copyright © 2002 M. J. Dominus |