jackr1909 Posted August 19, 2012 Share Posted August 19, 2012 Hi, I have a function that converts URL's in a string to links: $return = preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $return); Can i have some help amending it to exclude any links that are in quotes. Thanks Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted August 19, 2012 Share Posted August 19, 2012 The easiest way is to use RegEx to exclude any links that are in quotes. Quote Link to comment Share on other sites More sharing options...
jackr1909 Posted August 19, 2012 Author Share Posted August 19, 2012 How would i apply that? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 19, 2012 Share Posted August 19, 2012 Try putting a negated quote match just before the http" $return = preg_replace('@[^"\'](https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $return); 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.