I'm using the following pattern to capture links, and turn them into HTML friendly links. I use the following pattern in a preg_replace_callback and for the most part it works.
"#(https?|ftp)://(\S+[^\s.,>)\];'\"!?])#"
But this pattern fails when the text reads like so:
http://mylink.com/page[/b]
At that point it captures the [/b amusing it is part of the link, resulting in this:
<a href="http://woodmill.co.uk[/b">woodmill.co.uk[/b</a>]
I've look over the pattern, and used some cheat sheets to try and follow what is happening, but it has foxed me. Can any of you code ninja's help?