escape sequences and string comparisons

jkndeja at my-deja.com jkndeja at my-deja.com
Wed Jan 10 04:39:31 EST 2001


Hello Fredrik

> jkndeja at my-deja.com talks to himself again:

one of the joys of posting, shurely... ;-/

> > - I still think this makes re.escape() less useful than it
> > might be. How about a function which turns a string into an
'escaped'
> > form such that it would be an 'exact' RE match with itself?
>
> That's *exactly* what re.escape() does, of course.

OK, perhaps I shouldn't have written 'RE' match above. What I was
hoping/expecting is that this:

>>> import re
>>> s = r'[123]'
>>> r = re.escape(s)
>>> r
'\\[123\\]'
>>> r == s
0
>>>

or something similar, would give 1, not zero

    Jon N


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list