Posted By

remotezygote on 09/24/09


Tagged

regex url


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Actually useful URL parsing RegEx


 / Published in: Regular Expression
 

Matches are as follows:

0 = protocol 1 = fqdn 2 = subdomain 3 = top level subdomain 4 = domain (blah.com) 5 = port 6 = path 7 = query string 8 = hash

  1. ^(http[s]?|ftp):\/?\/?((([^\.:\/\s]*\.?)*)\.([^\.:\/\s]+\.[^\.:\/\s]+)):?([0-9]+)?([\/\w\.+]*\/?)?\??([\w\-\.]+[^#?\s]+)?\??[^#]*#?([\w\-]+)?$

Report this snippet  

You need to login to post a comment.