I'm trying to write a Regex that extracts the subdomain/domain parts of a URL as separate strings.
I've tried this:
/^[^:]+:\/\/([^\.\/]+)(\.[^\.\/]+)+(?:\/|$)/
It should work against these URLs:
http;//www.mail.yahoo.co.uk/blah/blah
http;//test.test.again.mail.yahoo.com/blah/blah
I want to break it into it's parts like so:
["http://", "www", ".mail", ".yahoo", ".co", ".uk"]
["http://", "test", ".test", ".again", ".mail", ".yahoo", ".com"]
Now I'm only able to capture them as:
["http://", "www", ".uk"]
["http://", "test", ".com"]
Anyone know how I can fix my regex?