From the following text I wish to extract the following two strings:
ip-10-x-x-x.eu-west-2.compute.interna
And
topology.kubernetes.io/zone=eu-west-2a
Full blob:
ip-10-x-x-x.eu-west-2.compute.internal Ready <none> 18d v1.20.4-eks-1-20-1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/os=linux,node.app/name=all,topology.kubernetes.io/region=eu-west-2,topology.kubernetes.io/zone=eu-west-2a
Regex with Grep PCRE is being used to extract the strings.
The following regex works on https://regex101.com/
(((^ip.*?)(?=(\s)))(?:.*?)((?<=\,)(topology\.kubernetes\.io\/zone.*?)(?=(\s|$))))
But when running on on Bash v4.2 with Grep, it pulls back to full blob, rather than the regex groups, as seen here:
echo "ip-10-x-x-x.eu-west-2.compute.internal Ready <none> 18d v1.20.4-eks-1-20-1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/os=linux,node.app/name=all,topology.kubernetes.io/region=eu-west-2,topology.kubernetes.io/zone=eu-west-2a" | grep -oP "(((^ip.*?)(?=(\s)))(?:.*?)((?<=\,)(topology\.kubernetes\.io\/zone.*?)(?=(\s|$))))"
What am I missing here?