vscode-logfile-highlighter icon indicating copy to clipboard operation
vscode-logfile-highlighter copied to clipboard

Not able to enable case insensitive pattern match

Open ihatetoregister opened this issue 3 years ago • 3 comments

A regex with the flag /i should match regardless if the string contain upper of lower case letters. However, I am not able to make this work using this extension. Might be me that is just typing it wrong or else it would be good if this could be added.

Example input Error:

error:

Patterns

"pattern": "error/i" // not working
"pattern": "error\i" // surprisingly this this matches "error:" but vs code complain about invalid escape char
"pattern": "(?i)error" // "Error message: Regex of custom log message is invalid.

Looks like the flags are fixed in the code: result.push(new RegExp(pattern, 'gm'));

ihatetoregister avatar Sep 09 '21 13:09 ihatetoregister

I have briefly looked into this and I can't seem to find any documentation about inline modifiers in regexes used by VS Code. Do you have a link? When I try your examples they don't work, as you say.

If inline modifiers turn out to not be compatible, perhaps I could add an extra option with flags to use, something like this?

{
     "pattern": "foo",
     "regexFlags": "i",
     "foreground": "yellow"
},

emilast avatar Oct 07 '21 15:10 emilast

Not sure about VS code but in JS there is support: https://javascript.info/regexp-introduction

But I think your suggested solution should solve the issue.

ihatetoregister avatar Oct 07 '21 15:10 ihatetoregister

Would be nice to see the regexFlags option implemented trying to use the 's' flag to allow the dot character to represent new lines

dev-syn avatar Nov 30 '23 00:11 dev-syn

Finally, I have some news regarding this feature request. In 3.1.0, there is a new option "patternFlags" that can be used to make a pattern case insensitive. I hope this helps.

emilast avatar Jun 22 '24 20:06 emilast