red light before backslash in Sublime Text

Viewed 74

when I write the directory of the file, Sublime Text shows this annoying red light before some backslashes. How can I get this to go away?

note: The code runs without any errors. ST python screenshot

2 Answers

Sublime Text highlights raw strings starting with a lowercase r as Regular Expressions, which is why \c and \M are highlighted as an illegal escape character in regex. You'll also notice the different highlighting on \U, \h and \D in your screenshot.

To prevent Sublime Text from treating your raw string as a regular expression, simply use an uppercase R for the raw string, like: ST highlighting python code with raw strings and Windows paths

Replace backslash "\" instead of forelash "/"

or

use double backslashes "\\"

In Python, backslash means escape sext character.

Related