Home > Mobile >  .tmLanguage.json RegEx expression not working/leads to no syntax highlighting
.tmLanguage.json RegEx expression not working/leads to no syntax highlighting

Time:12-25

I want to highlight everything after "print" as a string, the problem is that this leads to no highlighting even though the regex, in theory, should work.

As an example replacing "match": with "begin":"somestring" and typing somestring into vscode, works.

This is the JSON for the specific section:

"afterprint": {
            "patterns": [
                {
                    "name": "string.quoted.double",
                    "match": "(?<=print)(?s)(.*$)"
                }
            ]
        }

regex101.com example/test

CodePudding user response:

I have managed to get this working on my side by removing the (?s), I am unsure why this is the case, maybe a bug or restricted regex. Anyways it solves your question, as everything after print gets highlighted

"afterprint": {
            "patterns": [
                {
                    "name": "string.quoted.double",
                    "match": "(?<=print)(.*$)"
                }
            ]
        }

Just to mention, other regex hasn't worked for me as well in foo.tmLanguage.json I have still not solved this "mystery".

  • Related