in reply to Re: Regexp: Match anything except a certain word
in thread Regexp: Match anything except a certain word
That's not how you use the negative lookahead. It won't work. For example,
and'<a href="..." target="...">' =~ / <a # Matches '<a'. .+? # Matches ' '. (?!target) # Matches. (/\Gtarget/ doesn't match.) .+? # Matches 'href="..." target="..."'. > # Matches '>'. /isx;
'<a target="..." href="...">' =~ / <a # Matches '<a'. .+? # Matches ' t'. (?!target) # Matches. (/\Gtarget/ doesn't match.) .+? # Matches 'arget="..." href="..."'. > # Matches '>'. /isx;
The common use of a negative lookahead is
/(?:(?!$re).)*/
See my earlier post for the fix.
|
---|
In Section
Seekers of Perl Wisdom