I need to run a regular expression to match part of a string. On OS X I would do:
echo "$string" | sed -E 's/blah(.*)blah/\1/g'
However, this use of sed
isn't compatible with other platforms, many of which would invoke the same command using sed -r
.
So what I'm looking for is either a good way to detect which option to use, or a widely available (and compatible) alternative to sed
that I can try to do the same thing (retrieve part of a string using a pattern).