Sublime Forum

[Solved] Invalid escape in the Sublime Text Project Settings' "file_regex"

#1

Invalid escape in the Sublime Text Project Settings’ “file_regex”

My regex is working very fine: https://regex101.com/r/kW1fX9/1
And this is simply stranger. How to escape the paren on the "file_regex"?

"build_systems":
[
    {
        "working_dir": "$project_path/scripting",
        // "selector": "source.AmxxPawn, source.AMXX", // comment this to build from everywhere
        
        "file_regex": "(^[a-zA-Z._-]+)\(([0-9]+)\) : (error.*)",
        "name": "Build Main file",
        "cmd": ["compile_and_install.bat", "1"],
        
        "target": "ansi_color_build",
        "syntax": "Packages/ANSIescape/ANSI.tmLanguage"
    }
]

0 Likes

#2

You need to double those slashes. Single slashes work well in regexes, but in your build system, they need to be encoded as a JSON string.

2 Likes

#3

Thanks @ig0774, I should know they need to be parsed twice, but I just didn’t try it:

0 Likes