vscode-logfile-highlighter
vscode-logfile-highlighter copied to clipboard
Not able to enable case insensitive pattern match
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'));
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"
},
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.
Would be nice to see the regexFlags option implemented trying to use the 's' flag to allow the dot character to represent new lines
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.