Friday, October 29, 2010

Regex for javascript to detect a URL

var regex = /\b([\d\w\.\/\+\-\?\:]*)((ht|f)tp(s|)\:\/\/|[\d\d\d|\d\d]\.[\d\d\d|\d\d]
\.|www\.|\.tv|\.ac|\.com|\.edu|\.gov|\.int|\.mil|\.net|\.org|\.biz|\.info|\.name|\.pro
|\.museum|\.co)([\d\w\.\/\%\+\-\=\&\?\:\\\"\'\,\|\~\;]*)\b/gi;

 

Online tester for javascript regex:

http://www.regular-expressions.info/javascriptexample.html

Short tutorial for regex in javascript:

http://www.regular-expressions.info/javascript.html

No comments:

Post a Comment