Confused by slash/escape in regexp

andrew cooke andrew at acooke.org
Sun Apr 11 19:18:30 EDT 2010


On Apr 11, 8:12 pm, Lie Ryan <lie.1... at gmail.com> wrote:
> In the first case, *python* will unescape the string literal '\x62' into
> letters 'b'. In the second case, python will unescape the double
> backslash '\\' into a single slash '\' and *regex* will unescape the
> single-slash-62 into 'b'. In the third case, *python* will unescape
> double backslash '\\' into single-slash '\' and byte-string-62 '\x62' to
> letter-b 'b', and regex received it as 'a\bc', which interpreted as a
> special character to regex:
> """
> \b       Matches the empty string, but only at the start or end of a word.
> """

ah, brilliant!  yes.  thank-you very much!

andrew



More information about the Python-list mailing list