Add link tags to strings that begin with http or https


/ Published in: JavaScript
Save to your folder(s)



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

Report this snippet


Comments


You need to login to view comments.