andreSmol
andreSmol

Reputation: 1038

Python 2.6 regex, escaping chars in windows

I have a regex that finds if there is a period or a " (quote char) or a word in a line. I have to escape the period and the " chars.

res = re.match(ur"\"|\.|\w+",line)

The regex seems to work in Linux but in Windows I amn getting a syntax error. Any suggestions?

Upvotes: 2

Views: 181

Answers (1)

stema
stema

Reputation: 92996

If you have double quotes in your string, then enclose your string in single quotes, so you don't need to escape the double quotes.

res = re.match(ur'"|\.|\w+',line)

Upvotes: 1

Related Questions