I need to fetch hostname from a fully qualified domain name String. All parental domain / subdomain / interface names should be stripped, i.e.
abc001 -> abc001 ## stays name ##
efg.fqdn.com -> efg ## only 1st/short name ##
mnop-int -> mnop ## only 1st/short name ##
help-adm.fqdn -> help ## only 1st/short name ##
I've tried various combinations similar to this:
(.*?)(?:.|-)
but it didn't help much.
PS: The regex should be a single-liner, as it is goes as an input in application.