Posted By

tomsyweb on 10/09/10


Tagged

regexp


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sharathreddyp
grandulgoliat
bobbym245


Add link tags to strings that begin with http or https


 / Published in: JavaScript
 

  1. str.replace(/((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1">$1</a>');

Report this snippet  

You need to login to post a comment.