York wrote:
> I have two backslash - a. and I want to replace them with one backslash,
> but I failed:
>
> >>> import re
> >>> a = ''
> >>> re.sub(r'', '\\', '')
John has already sorted the RE-specific part of the problem, but it's
also worth noting that using the RE engine for
York wrote:
> Oh, that's right, the second arg is escaped by re compiler too.
No, that's wrong, you [should] do the escaping, the compiler unescapes
:-)
Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list
Oh, that's right, the second arg is escaped by re compiler too.
Thank you, John.
York
John Machin wrote:
> York wrote:
>
>>I have two backslash - a. and I want to replace them with one backslash,
>>but I failed:
>>
>> >>> import re
>> >>> a = ''
>> >>> re.sub(r'', '\\', '')
>>Trac
York wrote:
> I have two backslash - a. and I want to replace them with one backslash,
> but I failed:
>
> >>> import re
> >>> a = ''
> >>> re.sub(r'', '\\', '')
> Traceback (most recent call last):
>File "", line 1, in ?
>File "/usr/lib/python2.3/sre.py", line 143, in sub
>
I have two backslash - a. and I want to replace them with one backslash,
but I failed:
>>> import re
>>> a = ''
>>> re.sub(r'', '\\', '')
Traceback (most recent call last):
File "", line 1, in ?
File "/usr/lib/python2.3/sre.py", line 143, in sub
return _compile(pattern,