Sublime Forum

How to ignore case when doing matching in language syntax

#1

This is a subpart of my language definition that I’m currently working, however I would like to know if I in some way can force the matching to ignore case?

{ “match”: “(dcl|DCL)(\s*)([A-Za-z0-9_])(\s)(.*)(;)”,
“name”: “variable.definition.pli”,
“captures”: {
“1”: { “name”: “keyword.source.pli” },
“3”: { “name”: “variable.parameter.pli” },
“5”: { “name”: “keyword.source.pli” }
},
“comment”: “Markup of dcl statements”
},

According to manual.macromates.com/en/regular_expressions there is some extended group, however I’m not sure how to activate it.
Looking forward to hear from you guys.

Thanks Stefan

0 Likes

#2

You just put (?i) at the beginning to turn on case insensitive mode. You can use (?-i) to turn it back off.

4 Likes

#3

So… if I use (?i)\bHello\b… will it work?
EDIT: It works!

0 Likes

#4

A bit of extra info:

from @OdatNurd, if you want to make the . match the \n too, just add this (?s) (same, (?-s) turns it back off)

0 Likes