Parsing Text Links And BBCode At The Same Time
I'm not sure if my subject for this is accurate but here is what I'm trying to do:
I want to be able to parse BB sytle code along with regular text links at the same time within the same string.
Here's what I mean...
I have links in a string that can appear in two forms simultaneously:
1) [ url=http://www.abc.com]abc[/url] (without the space of course)
2) http://www.abc.com
Both need to be converted to HTML links of the form <a href="http://www.abc.com">...</a>
I can do each operation on it's own without any problems but trying to differentiate between bbcode and regular text links is giving me some trouble.
I'm currently using the following code for converting links to HTML which works great for my purposes:
$text = eregi_replace("((ht|f)tp://www.|www.)([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})((/|?)[a-z0-9~#%&/'_+=:?.-]*)*)", "http://www.3", $text);
$text = eregi_replace("((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&'_+=:?.-]*)*)", "<a href="