Regular Expression/URL Matching help needed!
Posted: Thu Sep 12, 2002 3:03 pm
Hello,
I have a regular expression that matched URLs and turns them into links. I now need to make sure this happens only if the URL is NOT enclosed in square brackets.
So the url for yahoo would be rendered as a link here:
But not here:
Here's the regexp I'm using so far:
Any ideas? Thanks in advance!!
I have a regular expression that matched URLs and turns them into links. I now need to make sure this happens only if the URL is NOT enclosed in square brackets.
So the url for yahoo would be rendered as a link here:
Code: Select all
http://www.yahoo.com is a search engineCode: Select all
їhttp://www.yahoo.com] is a search engineHere's the regexp I'm using so far:
Code: Select all
$Text = preg_replace("/(ї\w]+:\/\/ї\w-?&;#~=\.\/\@]+ї\w\/])/i", "<a href="$1">$1</a>", $Text);