in reply to Heuristic for parsing Host name and domain

Also be mindful of the (very large...) set of routines in CPAN under the category Regexp::Common.

In general, “if you are looking for a regular expression that you suspect probably has been written before, it probably has.”   And if you are looking for something that might need more than just a regular expression, i.e. programmed logic of some kind ... once again, CPAN probably already has it.   Therefore, get into this habit (and I sorely wish I could take my own advice):   look before you code.