Assume a text string my_string
$ my_string="foo bar=1ab baz=222;"
I would like to extract the alphanumeric string between keyword baz and the semi-colon.
How do I have to modify the following grep code using regex assertions to also exclude the trailing semi-colon?
$ echo $my_string | grep -oP '(?<='baz=').*'
222;
foo baz=x; bar=y;? (xorx; bar=y?). And forbaz=x; baz=y;?