Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Regexp: Match anything except a certain word

by ikegami (Pope)
on Apr 21, 2006 at 17:15 UTC ( #544950=note: print w/replies, xml ) Need Help??

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,

'<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


See my earlier post for the fix.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://544950]
[LanX]: there are template variables to "Auto-populate" it
[marinersk]: Yeah, someday I might become interested enough to poke around PerlMonks more internally. Most of the fancy stuff is way down on my to do list.
[LanX]: Yeah ...
[LanX]: no variable for votes_left
[marinersk]: Ah, well. I will continue to deal with it, as I have. Thanks for poking about, though.
[LanX]: you are welcome! :)
[marinersk]: LanX, your link to Darmstadt on your Home Node is broken.
erix tsk-tsks

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-05-29 14:29 GMT
Find Nodes?
    Voting Booth?