【问题标题】:fatal: command line, '\/\/( ){0,}beforeEach\(async\(\(\) => \{$': Unmatched \{致命:命令行,'\/\/( ){0,}beforeEach\(async\(\(\) => \{$': 不匹配 \{
【发布时间】:2020-08-15 07:24:42
【问题描述】:

我正在寻找一些测试被注释的文件列表

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

来自https://regex101.com/

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

工作正常,...但在终端内我得到了

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

【问题讨论】:

  • 如果您需要符合 POSIX BRE 的正则表达式,您需要知道如何将 regex101 正则表达式“转换”为那些。试试git grep "// *beforeEach(async(() => {$"
  • 谢谢!!!它有效!

标签: regex git typescript git-grep


【解决方案1】:

您需要确保该模式符合 POSIX BRE 标准。

使用

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

也就是说,POSIX BRE 表达式中的( 匹配文字(,而{ 匹配文字{

当您转义左大括号\{ 时,它会启动一个范围量词,因此\} 是预期的,因此是错误Unmatched \{

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 2015-02-21
    • 1970-01-01
    • 2022-01-18
    • 2015-04-02
    • 1970-01-01
    相关资源
    最近更新 更多