fatal: command line, '\/\/( ){0,}beforeEach\(async\(\(\) => \{$': Unmatched \{

79 Views Asked by At

I am looking for the list of files where some tests are commented like

//     beforeEach(async(() => {
//   beforeEach(async(() => {
 //     beforeEach(async(() => {
//    beforeEach(async(() => {

From https://regex101.com/

\/\/( ){0,}beforeEach\(async\(\(\) => \{$

works fine, ... but inside the terminal I got

git grep "\/\/( ){0,}beforeEach\(async\(\(\) => \{$"
fatal: command line, '\/\/( ){0,}beforeEach\(async\(\(\) => \{$': Unmatched \{
1

There are 1 best solutions below

0
On BEST ANSWER

You need to make sure the pattern complies with the POSIX BRE standard.

Use

git grep "// *beforeEach(async(() => {$"

That is, ( in a POSIX BRE expression matches a literal ( and { matches a literal {.

When you escape the open brace, \{, it starts a range quantifier, and thus \} is expected and hence is the error, Unmatched \{.