Visual studio code 非固定字符长度后的文本匹配查找
我正在为Visual Studio代码不支持的编程语言编写语法突出显示。突出显示工作正常,但我在突出显示以下代码时遇到了一个问题:Visual studio code 非固定字符长度后的文本匹配查找,visual-studio-code,syntax-highlighting,regex-lookarounds,textmate2,oniguruma,Visual Studio Code,Syntax Highlighting,Regex Lookarounds,Textmate2,Oniguruma,我正在为Visual Studio代码不支持的编程语言编写语法突出显示。突出显示工作正常,但我在突出显示以下代码时遇到了一个问题: pool[] Test1 t1; pool[1] Test2 t2; pool[10] Test3 t3; 我使用以下方式突出显示“池”一词: 它正在工作,但我想强调一下Test1、Test2和Test3 我唯一的想法是用消极的眼光看后面,就像这样: (?<=pool\[\d*\]\s+)([A-Z])\w+ (?您可以使用捕获组。这里我捕获了3个组,但只
pool[] Test1 t1;
pool[1] Test2 t2;
pool[10] Test3 t3;
我使用以下方式突出显示“池”一词:
它正在工作,但我想强调一下Test1、Test2和Test3
我唯一的想法是用消极的眼光看后面,就像这样:
(?<=pool\[\d*\]\s+)([A-Z])\w+
(?您可以使用捕获组。这里我捕获了3个组,但只为第2个组分配了一个范围
"storages": {
"patterns": [{
"match": "^(\w+\[\d*\])\s+(\w+)\s+(\w+);$",
"captures": {
"2": {
"name": "storage.type.ceu"
}
}
}]
},
非常感谢。这个解决方案非常有效。
(?=subexp) look-ahead
(?!subexp) negative look-ahead
(?<=subexp) look-behind
(?<!subexp) negative look-behind
Subexp of look-behind must be fixed-width.
But top-level alternatives can be of various lengths.
ex. (?<=a|bc) is OK. (?<=aaa(?:b|cd)) is not allowed.
In negative look-behind, capturing group isn't allowed,
but non-capturing group (?:) is allowed.
"storages": {
"patterns": [{
"match": "^(\w+\[\d*\])\s+(\w+)\s+(\w+);$",
"captures": {
"2": {
"name": "storage.type.ceu"
}
}
}]
},