What is the correct syntax for finding a substring (a string which is preceded and followed by specific strings) which does not match a specific pattern?
For example, I want to take all substrings which start with
BEGIN_, end with
_END and the substring in between is not equal to
FOO; and replace the whole substring with the format "(inner substring)". The following would match:
BEGIN_FOO_END would not match.
I have played around with the following, but cannot seem to find the correct syntax:
sed -e 's/BEGIN_(^FOO)_END/($1)/g' sed -e 's/BEGIN_([^FOO])_END/($1)/g' sed -e 's/BEGIN_(?!FOO)_END/($1)/g' sed -e 's/BEGIN_(!FOO)_END/($1)/g' sed -e 's/BEGIN_(FOO)!_END/($1)/g' sed -e 's/BEGIN_!(FOO)_END/($1)/g'