how to detect escape characters in a string

Posted by mix on Stack Overflow See other posts from Stack Overflow or by mix
Published on 2010-06-13T01:52:48Z Indexed on 2010/06/13 2:02 UTC
Read the original article Hit count: 215

Given a string named line whose raw version has this value:

\rRAWSTRING

how can I detect if it has the escape character \r? What I've tried is:

if repr(line).startswith('\r'):
    blah...

but it doesn't catch it. I also tried find, such as:

if repr(line).find('\r') != -1:
    blah

doesn't work either. What am I missing?

thx!

© Stack Overflow or respective owner

Related posts about python

Related posts about parsing