Posted By

spark9 on 10/21/09


Tagged

parse links


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tclancy


Create/parse links from text in jQuery


 / Published in: jQuery
 

URL: http://devkick.com/blog/parsing-strings-with-jquery/

  1. $.fn.clickUrl = function() {
  2. var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
  3. this.each(function() {
  4. $(this).html(
  5. $(this).html().replace(regexp,'<a href="$1">$1</a>')
  6. );
  7. });
  8. return $(this);
  9. }

Report this snippet  

You need to login to post a comment.