Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

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
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 .