i need a regular expression to capture a given URLs SLD.
Examples:
jack.bop.com -> bop
bop.com -> bop
bop.de -> bop
bop.co.uk -> bop
bop.com.br -> bop
All bops :). So this regex needs to ignore ccTLDs, gTLDs and ccSLDs. The latter is the difficult part, since i wanna keep the regex as un-complex as possible.
The first task would be to remove ccTLDs then gTLDs, and then check for ccSLDs and remove them if present.
Any help is much appreciated :)
--
If it helps, ccTLDs are matched by:
\.([a-z]{2})$
And gTLDs are matched by:
\.([a-z]{3-6})$
Luckily it's two mutually exclusive patterns.