Posted By

brandonjp on 11/13/12


Tagged

regex url http regexp https


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

montujj


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


 / Published in: Regular Expression
 

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

  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  

You need to login to post a comment.