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?
This might work for you:
sed 'h;s/BEGIN_\(.*\)_END/(\1)/;/^(FOO)$/g' file
This only works if there is only one string per line.
For multiple strings per line:
sed 's/BEGIN_\([^F][^_]*\|F[^O][^_]*\|FO[^O][^_]*\|FOO[^_]\+\)_END/\(\1\)/g' file
Or the more easily understood:
sed 's/\(BEGIN_\)FOO\(_END\)/\1\n\2/g;s/BEGIN_\([^\n_]*\)_END/(\1\)/g;s/\n/FOO/g' file