Sublime Forum

Python Regex String Parser Bug

#1

Heyo,

There’s a bug in the string parser (but only for regex strings). This snippet is 100% valid Python, but causes all text after it to be highlighted incorrectly:

year_r = re.compile(r"""
    (?:\(|\|'|\s)      # Match any opening (, , '
    (\d{2}|\d{4})       # Match any 2 or 4 digit number
    (?:\)|\]|$)         # Match any closing (, , or whitespace, or string end
    """, re.VERBOSE)

Removing the r on “”" causes it to highlight correctly.

0 Likes