Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

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


in reply to Re^2: Regexp: Match anything except a certain word
in thread Regexp: Match anything except a certain word

Oops, I read the problem too fast. Fix:

$test =~ s{ ( <a\s (?:(?!target=|>).)* href="http:// (?:(?!target=|>).)* ) (?=>) }{$1 target="_blank"}xsgi;

Alternatively, the following *might* be faster, especially considering href is usually the first attribute:

$test =~ s{ ( <a\s (?:(?!href=|target=|>).)* href="http:// (?:(?!target=|>).)* ) (?=>) }{$1 target="_blank"}xsgi;

Tested.

Update: Collapsed (?!..re1..)(?!..re2..) into (?!..re1..|..re2..)


Comment on Re^3: Regexp: Match anything except a certain word
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://544954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2014-12-18 18:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (59 votes), past polls