I have a string of colon separated assignments, each of which is of the form a=b. I need to parse it to extract foo, where foo is ...:di=foo:.... The assignment di=foo could happen at the beginning, in the middle, or at the end of the string.
My idea was to match either a beginning of line or a colon, then the string di=, then every character except a colon, then a colon or an end of line.
I've only managed to get the "every character except a colon" part to work.
Some tests:
echo "di=a;b:*.di=c;d:ddi=e;f" | sed "s/.*di=\([^:]*\):.*/\1/" echo "ddi=a;b:di=c;d:*.di=e;f" | sed "s/.*di=\([^:]*\):.*/\1/" echo "*.di=a;b:ddi=c;d:di=e;f" | sed "s/.*di=\([^:]*\):.*/\1/" the first one should return a;b, the second one c;d and the third one e;f, but for now they all return c;d.
mlr --fs : --onidx cut -f di