freshwebs Posted November 7, 2006 Share Posted November 7, 2006 So I'm an idiot with regular expressions, I can't ever seem to figure them out. Could someone help me make a regular expression that will find all the anchors in a block of text and add a target="_blank" attribute to them? It would be [i]greatly[/i] appreciated.Thanks!!! Quote Link to comment Share on other sites More sharing options...
Nicklas Posted November 8, 2006 Share Posted November 8, 2006 [code]$string = preg_replace('/(<a href[^<>]+)>/is', '\\1 target="_blank">', $string);[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.