Regex for url formatting (www.domain.tld to anchors)

Posted by Kristaps on Stack Overflow See other posts from Stack Overflow or by Kristaps
Published on 2010-05-19T22:11:32Z Indexed on 2010/05/19 22:30 UTC
Read the original article Hit count: 327

Filed under:
|
|
|
|

Hi. I'm currently developing a little browser-based Twitter widget.

Currently, I'm stuck with getting the URLs to work. I'm kinda newbie, when it comes to regex (I know, how to get parts of a string, but this one – tough one).

So, I need a regex that would search/replace

www.domain.tld -> <a href="http://www.domain.tld">http://www.domain.tld</a>

With/without http://, preferably.

Any advice is welcome. Thanks.

© Stack Overflow or respective owner

Related posts about regex

Related posts about php