VSCode问题匹配器正则表达式与我的错误输出不匹配

时间:2018-09-28 19:31:47

标签: visual-studio-code vscode-tasks

我正在尝试为VSCode ProblemMatcher.匹配这种格式的错误。

C:\projects\folder\main.cpp(6) : Error[AA000]: identifier "level2" is undefined
C:\projects\folder\main.cpp(7) : Error[AA000]: identifier "level3" is undefined

使用regex101.com,我可以使用此regex满足我的需求...

^([][{} \t#%$~A-Za-z0-9_:+\.-\\]+)\(([0-9]+)\) (:) (Warning|Error)(.*)$

A,当将(带有希望的)正确的转义斜杠放入我的task.json文件时,在运行将在VSCode终端中生成这些错误的任务之后,我在“问题”选项卡中没有收到任何输出。

// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [      
    {           
        "label": "build simple regex",
        "type": "shell",
        "command": "iarbuild iar_ewb_build_timer.ewp -make Debug -log errors -parallel 8",  
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher": {
            "fileLocation": "absolute",
            "pattern": {
                "regexp": "^([][{} \\t#%$~A-Za-z0-9_:+\\.-\\\\]+)\\(([0-9]+)\\) (:) (Warning|Error)(.*)$",
                "file": 1,
                "line": 2,
                "severity": 4,
                "message": 5
            }
        }
    },
]
}

我的Regex也许有问题。有帮助吗?

1 个答案:

答案 0 :(得分:0)

我能够通过原始帖子中的错误代码来解决这个问题。谢谢您的答复!

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {           
        "label": "build simple regex",
        "type": "shell",
        "command": "iarbuild iar_ewb_build_timer.ewp -make Debug -log errors -parallel 8",  
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "problemMatcher": {
            "fileLocation": "absolute",
            "pattern": {
                "regexp": "^([#%$~A-Za-z0-9_:+-\\\\]+)[(]([0-9]+)[)] (:) (Warning|Error)(.*)$",
                "file": 1,
                "line": 2,
                "severity": 4,
                "message": 5
            }
        }
    },
]
}