简体   繁体   English

在Sublime文本2.02中使用正则表达式查找模式

[英]Find pattern with regex in Sublime text 2.02

I would like to create a new Syntax Rule in Sublime in order to search a string pattern so that that pattern is highlighted. 我想在Sublime中创建一个新的语法规则,以便搜索字符串模式,以便突出显示该模式。 The parttern I am looking for is IPC or TST, therefore I was making use of the following Sublime Syntax rule 我正在寻找的合作伙伴是IPC或TST,因此我在使用以下Sublime语法规则

{ "name": "a3",
  "scopeName": "source.a3",
  "fileTypes": ["a3"],
  "patterns": [

    {  "name": "IPC",
       "match": "\\b\\w(IPC|TST)\\w\\b "
    }
  ],
  "uuid": "c76f733d-879c-4c1d-a1a2-101dfaa11ed8"
}

But for some reason or another, it doesn't work at all. 但是由于某种原因,它根本不起作用。

Could someone point me out in the right direction? 有人可以指出我正确的方向吗?

Thanks in advance 提前致谢

After looking around and testing a lot, I have found the issue, apparently apart from identifying the patter, I should invoke the colour, for doing it I have to make use of "capture", being the command as follows: 经过四处检查和测试后,我发现了这个问题,显然除了识别模式外,我还应该调用颜色,为此,我必须使用“捕获”功能,其命令如下:

  { "name": "IPC colour",
    "match": "\\b(IPC|TST)\\b",
    "captures": {
        "1": { "name": "meta.preprocessor.diagnostic" }
        }
  },

Where "name": "meta.preprocessor.diagnostic" will indicate the sort of colour assign to the found pattern. 其中“名称”:“ meta.preprocessor.diagnostic”将指示分配给找到的图案的颜色种类。

regards! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM