I am using ereg_replace to find a link in some content and turn it into an actual hyperlink.
To enter a link, users type in either:
[L]http://www.link.com[EL] which displays just the link
or they type in:
[L=http://www.link.com]Click here[EL] and the words "Click here" become the hyperlink.
The code I have been using shows below and it works fine EXCEPT when the link includes the word "Sub". (Our site does include "sub-pages" where the URL looks like http://www.site.com?section=Section+Sub&id=1) When Sub is present, the display is just as entered -- [L]http://www.site.com?section=Section+Sub&id=1[EL]
Here's the code I'm using to replace the [L]...[EL] content. Any ideas why this doesn't work when Sub is present? Thanks for your help!
$content = ereg_replace("[L]([-_./a-zA-Z0-9!&%#?,'=:~]+)[EL]", "<a href=\"\1\" target=\"_blank\">\1</a>", $content);
$content = ereg_replace("[L=([-./a-zA-Z0-9!&%#?,'=:~]+)]"."([-./a-zA-Z0-9 !&%#?,'=:~]+)[EL]", "<a href=\"\1\" target=\"_blank\">\2</a>", $content);