regex needed to strip out domain name -


i need regexp strip out domain name part of url. example if had following url:

http://www.website-2000.com

the bit i'd want regex match 'website-2000'

if explain each part of regex me understand great.

thanks

this 1 should work. there might faults it, none can think of right now. if want improve on it, feel free so.

/http:\/\/(?:www\.)?([a-z0-9\-]+)(?:\.[a-z\.]+[\/]?).*/i  http:\/\/            matches "http://" part (?:www\.)?           non-capturing group matches 0 or 1 "www." ([a-z0-9\-]+)        capturing group matches character ranges a-z, 0-9                      in addition hyphen. wanted extract. (?:\.[a-z\.]+[\/]?)  non-capturing group matches tld part (i.e. ".com",                      ".co.uk", etc) in addition 0 or 1 "/" .*                   matches rest of url 

http://rubular.com/r/roz13nswbq


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -