I have asked a question insert a string to a list variables in text file [use sed]

In which @RomanPerekhrest showed me a different regex syntax.

\(=([^)]*\)) can capture [^)]* as group 1 . This is confusting for me .

You can check the result on https://regex101.com/r/DRChkE/2

enter image description here enter image description here


enter image description here

This \(([^\)]*)\) is the correct one in my mind, but it is broken in sed.

So I wonder how to make sed use the regex syntax standard as python or javascript (common standard in many languages).


1 Answer 1


You're looking for Perl-style aka PCRE regular expressions but that isn't a POSIX conforming syntax and not supported by typical implementations of the standard command-line tools like sed. What is supported are the syntax known as Basic Regular Expression (BRE) and Extended Regular Expression (ERE). In sed the former is the default and the latter is enabled with -E (in GNU sed -r also works).

You'll occasionally see versions of standard tools with some support for PCRE (e.g. GNU's grep has the -P flag) but this is the exception not the norm.

See the Standards section of Wikipedia's regex page for details.

Not the answer you're looking for? Browse other questions tagged .