« Return to Thread: sed to python: replace Q

Re: sed to python: replace Q

by happyriding :: Rate this Message:

Reply to Author | View in Thread

On Apr 29, 11:27 pm, Raymond <not-for-m...@...> wrote:
> For some reason I'm unable to grok Python's string.replace() function.

line = "abc"
line = line.replace("a", "x")
print line

--output:--
xbc

line = "abc"
line = line.replace("[apq]", "x")
print line

--output:--
abc


Does the 5 character substring "[apq]" exist anywhere in the original
string?
--
http://mail.python.org/mailman/listinfo/python-list

 « Return to Thread: sed to python: replace Q