[Tutor] "replace" in String module

Lindsay Davies Lindsay.Davies@moonshine.co.uk
Tue, 30 Jan 2001 13:59:48 +0000


Try...

	string.replace(test,"<line>", "<dorm>")

The parameters are (str, old, new, [maxsplit]).

You will also probably want to investigate the re module some time soon.

Best wishes,

Lindsay


On 1/30/01, Sharriff Aina wrote about '[Tutor] "replace" in String module':
>Hi Guys!
>
>Why does this fail?
>
>>>>  import string
>>>>  test = "<line> the line </line>"
>>>>  string.find(test, "<line>")
>0
>  >>> string.replace(test, "<dorm>", "<line>")
>'<line> the line </line>'
>>>>
>
>I would have thought that the "</line>" would have been left untouched.
>
>
>regards
>
>Sharriff
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor