I start with this PHP string.
$bodyString = '
another 1 body
reg http://www.regularurl.com/home
secure https://facebook.com/anothergreat.
a subdomain http://info.craig.org/
dynamic; http://www.spring1.com/link.asp?id=100408
www domain; at www.wideweb.com
single no subdomain; simple.com';
Need to turn all domains, urls into anchor(<a>) elements.
preg_replace('#[-a-zA-Z0-9@:%_\+.~\#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~\#?&//=]*)?#si', '<a href="$0">$0</a>', $bodyString)
$bodyString result:
'another 1 body
reg <ahref="http://www.regularurl.com/home">http://www.regularurl.com/home</a>
secure <a href="https://facebook.com/anothergreat.">https://facebook.com/anothergreat.</a>
a subdomain <a href="http://info.craig.org/">http://info.craig.org/</a>
dynamic; <a href="http://www.spring1.com/link.asp">http://www.spring1.com/link.asp</a>?id=100408
www domain; at <a href="www.wideweb.com">www.wideweb.com</a>
single no subdomain; <a href="simple.com">simple.com</a>';
Result: All urls, domains are turned into <a> except http://www.spring1.com/link.asp?id=100408
What is missing in the regex to make this work?