Regular Expression for Matching URLs with or without http(s)


/ Published in: Regular Expression
Save to your folder(s)

thanks to...
http://gskinner.com/RegExr/
http://daringfireball.net/2010/07/improved_regex_for_matching_urls


Copy this code and paste it in your HTML
  1. (?:(?:http|https):\/\/)?([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?
  2.  
  3. RegExp: /(?:(?:http|https):\/\/)?([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi
  4. pattern: (?:(?:http|https):\/\/)?([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?
  5. flags: gi
  6. 1 capturing groups:
  7. group 1: ([-a-zA-Z0-9.]{2,256}\.[a-z]{2,4})

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.