On my website users have an ability to create articles, using simple text editor. Usually in that articles i see links like this: http://example.com as a plain text. I need a simple PHP-function to convert such links to this:
<a href="http://example.com">http://example.com</a>
First i was thinking about simple regex replace, but what if user saves article the second time? This code will be regex'ed once more:
<a href="http://example.com">http://example.com</a>
becomes
<a href="<a href="http://example.com">http://example.com</a>"><a href="http://example.com">http://example.com</a></a>
Any suggestions, how to solve this problem?
EDITED: I used lots of regexes, the last one was:
/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\/\S*)+?/