What is the regular expression SO/SE sites use for making the hyperlink active?
There is a problem if the hyperlink is in the sentence, that it might be followed by interpunction. I see that if there is a dot or parenthesis at the end of hyperlink, it is not considered its part. So is it something like this?
preg_replace('/(https?:\/\/\S+[^),.?!])/', '<a href="\1">\1</a>', $s);
But I've seen a link which ended by
. (dot), so this would break it.
It seems this will never work 100% (it can't), but I'm wondering what would be the optimal as-tweaked-as-possible solution.