Hi,
I found a great example of ereg_replace to add html formatting to urls that don't have them. The problem is, it also formats the "domain.com" portion of email addresses (I have another ereg_replace to take care of them). So while
www.domain.com
becomes
<a href="http://www.domain.com">www.domain.com</a>
bob@domain.com
becomes
bob@<a href="http://domain.com">domain.com</a>
So I want to add something to this ereg so it only finds examples that are NOT preceded by the "@" symbol. I'm just not sure how to format it.
Here's the code as it stands (the creator broke it out into separate variables, for the sake of neatness I think):
$vdom = "[:alnum:]"; // Valid domain chars
$vurl = $vdom."_~-"; // Valid subdomain and path chars
$vura = $vurl."A-?a-y!#$%&*+,;=@."; // Valid additional parameters (after '?') chars;
// insert other local characters if needed
$protocol = "[[:alpha:]]{3,10}://"; // Protocol exp
$server = "([$vurl]+[.])+[$vdom]+"; // Server name exp
$path = "(([$vurl]+([.][$vurl]+)*/)|([.]{1,2}/))*"; // Document path exp (/.../)
$name = "[$vurl]+([.][$vurl]+)*"; // Document name exp
$params = "[?][$vura]*"; // Additional parameters (for GET)
$output = ereg_replace("($protocol)?($server(/$path($name)?)?)", "<a href=\"http://\\2\">\\0</a>", $input); // URL into links
Any idea how to get this to do its thing only if there's NO "@" immediately before?
(Ironically, when I preview this post, I see that the PHP Builder board correctly formats the URL as a URL and the email as an email. Now if I could get that code...)