Replacing "\"s using re.sub

Moshe Zadka moshez at math.huji.ac.il
Sat Feb 19 14:25:48 EST 2000


On Sat, 19 Feb 2000, Edward C. Jones wrote:

> I need to replace all instances of "\" in a string with "\\". The
> function "re.sub" looks like the way to do it. "re.sub" is called
> by "re.sub(pattern, repl, string)". For my problem what should
> "pattern" and "repl" be?

If you're looking to *replace* one *string* with another, why not go
for string.replace?
--
Moshe Zadka <mzadka at geocities.com>. 
INTERNET: Learn what you know.
Share what you don't.





More information about the Python-list mailing list