Re: Confused by slash/escape in regexp

2010-04-11 Thread MRAB
andrew cooke wrote: Is the third case here surprising to anyone else? It doesn't make sense to me... Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type "help", "copyright", "credits" or "license" for more information. from re import com

Re: Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
On Apr 11, 7:18 pm, Paul McGuire wrote: [...] > > So I would say the surprise isn't that case 3 didn't match, but that > case 2 matched. > > Unless I just don't get what you were testing, not being an RE wiz. Case 2 is the regexp engine interpreting escapes that appear as literal strings. It's w

Re: Confused by slash/escape in regexp

2010-04-11 Thread Paul McGuire
On Apr 11, 5:43 pm, andrew cooke wrote: > Is the third case here surprising to anyone else?  It doesn't make > sense to me... > > Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) > [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 > Type "help", "copyright", "credits" or "license" for more in

Re: Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
On Apr 11, 8:12 pm, Lie Ryan 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, *p

Re: Confused by slash/escape in regexp

2010-04-11 Thread Lie Ryan
On 04/12/10 08:43, andrew cooke wrote: > > Is the third case here surprising to anyone else? It doesn't make > sense to me... > > Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) > [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 > Type "help", "copyright", "credits" or "license" for more

Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
Is the third case here surprising to anyone else? It doesn't make sense to me... Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from re import compile >>> p1 = comp