Regex Grouping (Retrieve subdomain) -


i'm trying write regex match url subdomain excluding "www". trying retrieve subdomain after match can't seem group correctly. first group matches whole url. allow lower case letters, numbers , "-" in subdomain. need retrieve subdomain if pattern matches

^(((?!www)[a-z0-9\\-]*))+(\\.)+?example\\.com.*$ 

/^(?!www)([a-z0-9\-]+)\.example\.com.*$/ 

group 0 have whole url, , group 1 contain subdomain


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -