Sublime Forum

Syntax coloring in Python: problem with regular expressions

#1

I’m working with a new code base and I ran in a problem which bugs the syntax coloring in Python.
Basically, this line bugs the syntax coloring so that everything after is colorized as a regex :

result2 = something.re_compile(r'''\] ^]*  \]''', re.VERBOSE)

Case in point:

The coloration works back if I remove the “r” before the string or if I “close” the brackets :

result2 = something.re_compile('''\] ^]*  \]''', re.VERBOSE)
# or
result2 = something.re_compile(r'''\] ^]]*  \]''', re.VERBOSE)

Obviously this changes the meaning of the code, but it might help you diagnose the problem.

0 Likes