gpt4 book ai didi

regex - Visual Studio Code 任务正则表达式未捕获构建错误输出

转载 作者:行者123 更新时间:2023-11-29 08:33:19 27 4
gpt4 key购买 nike

我的 Regex 在解析 rustc 的构建输出时遇到了一些问题。

输出看起来像

   Compiling svd2rust v0.2.1 (file:///C:/trust/svd2rust)
error: expected one of `=>`, `@`, `if`, or `|`, found `Some`
--> src\main.rs:56:9
|
56 | Some("all") =>
| ^^^^
error: aborting due to previous error
error: Could not compile `svd2rust`.
To learn more, run the command again with --verbose.

我现在的任务是这样的:

{
"version": "0.1.0",
"command": "cargo",
"isShellCommand": true,
"args": ["build"],
"problemMatcher": {
"owner": "build",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "(error):(.*)\\s+-->\\s+(.*):(\\d+):(\\d+)",
"file": 3,
"line": 4,
"column": 5,
"severity": 1,
"message": 2
}
}
}

According to regex101 , 看起来正则表达式应该匹配相应的部分。

最佳答案

根据VS Code documentation ,您需要一个多行问题匹配器。这可能有效;我没有测试它:

{
"version": "0.1.0",
"command": "cargo",
"isShellCommand": true,
"args": ["build"],
"problemMatcher": {
"owner": "build",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": [{
"regexp": "(error):(.*)",
"severity": 1,
"message": 2
},{
"regexp": "-->\\s+([^:]*):(\\d+):(\\d+)",
"file": 1,
"line": 2,
"column": 3
}]
}
}

关于regex - Visual Studio Code 任务正则表达式未捕获构建错误输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41921208/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com