I have never used regex before and I was wondering how to write a regular expression in PHP that gets the domain of the URL. For example:
http://www.hegnar.no/bors/article488276.ece –> hegnar.no
I have never used regex before and I was wondering how to write a
Share
Just use
parse_url()if you are specifically dealing with URLs.For example:
Docs
EDIT:
To take out the www. infront, use: