Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Regexp: Match anything except a certain word

by TedPride (Priest)
on Apr 21, 2006 at 18:25 UTC ( [id://544960]=note: print w/replies, xml ) Need Help??


in reply to Regexp: Match anything except a certain word

The following seems to work:
$_ = join '', <DATA>; s/(<a href="https?:\/\/(?:(?!target=).)*?)>/$1 target="_blank">/igs; print; __DATA__ <a href="dsfsdf">sdfdsf</a> <a href="http://dsfsdf">sdfdsf</a> <a href="https://dsfsdf">sdfdsf</a> <a href="http://dsfsdf" target="_blank">sdfdsf</a> <a href="http://dsfsdf" >sdfdsf</a>

Replies are listed 'Best First'.
Re^2: Regexp: Match anything except a certain word
by ikegami (Patriarch) on Apr 21, 2006 at 19:23 UTC

    You're assuming the target will come after the href, but the OP allowed for any order.

    See my earlier post for the fix.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found