Message 337272 - Python tracker (original) (raw)

Problem:

re.match("\-", "\-")

returns None. I expected a match.

Context:

I have some random text strings I want to match against. I'm using re.escape() to ensure that the text characters are not interpreted as special characters: re.match(re.escape("-"), re.escape("-"))

As a result, strings with hyphens are coming back as above, and are not matching.