I'm pretty sure it should be simple enough to do but I cannot figure out. I have some FQDNs like:
- api.mydiomain.org.local
- app.stg.mydiomain.org.local
- uses.anotherdomain.uk
and I like to extract mydiomain.org.local, stg.mydiomain.org.local, anotherdomain.uk etc. respectively using perl style regex. I tried [\\W].+$
, which is giving me almost what I want but with the leading .
(e.g. .mydiomain.org.local
). And [^\\W]+$
returning only the very last part (e.g. local
). Any idea what am I missing here?
Just to mention that I'll be using this with terraform's regex()
function, which is fully compatible with perl RegEx but if the pattern has no capture groups it returns a string but behaves differently for named and unnamed capture group(s), returning a map{} and list() instead.