i got links for example:
abc.pri-from-somestring
abc-de.pri-idx-somestring
abc.org.au-sop-somestring
the result mi looking for from the example links is"
abc.pri
abc-de.pri
abc.org.au
what im trying to get is the domain out of those string combinations. the main problem is that links can have dashes in them or 2 dots so im stuck.
i did many splits and join but there is many combinations. i think the best way is with regex and i don't have enough experience with. any other solution will be fine. this works but only if there is a dash after the domain ^([^-\d] )
any help will be very appreciated thanks
CodePudding user response:
Something like this should work:
^.*[.][^-]*
Basically just get everything up until and including the last dot, and then get every up until but excluding the last dash (if one exists).