I need to fix this regex to grab the domain only. no subdomain, folders or files name after the top level domain. I have started it. I need help fixing the regex
There are many variations to take into consideration:
- http or https
- www or not
- multiple subdomains
- slash in the end of url
- folder after top level domain
Here is the link with the first part done Link
The top 5 is working but the bottom 3 with folder and filename is not.
Here is my regex so far
/([a-zA-Z0-9-]+)(\.[a-zA-Z]{2,5})?(\.[a-zA-Z]+$)
The results should be:
- domain.com
- masterdomain.com.au
- luxury.co.uk
- globo.us
- test.com
- google.com.br