What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 150 Stack Exchange communities.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted


share|improve this answer
Uh! Thanks!!!!! – Tomas Feb 11 '12 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .