world wide web.site.co.united kingdom
world wide web.subdomain.site.co.united kingdom
were put in the function they'd be came back as "site.co.united kingdom".
I'd say there's a regex means to fix this, but it will likely be complicated. You'll have to discover the last occurrence from the '.' and obtain what's next, then you need to get what's between your last and 2nd to last '.', then get anything prior to the second to last period, as much as the 3rd right (subdomain) '.'.
Does which make sense?? I am unsure from the regex needed, but here are a few questions about To enable you to get began...