简体   繁体   中英

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. The parttern I am looking for is IPC or TST, therefore I was making use of the following Sublime Syntax rule

{ "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.

regards!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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