trouble with replace
Anthra Norell
anthra.norell at tiscalinet.ch
Sun Aug 13 05:42:19 EDT 2006
This might well take the trouble out ot the OP's replace:
http://cheeseshop.python.org/pypi/SE/2.2%20beta
Regards
Frederic
----------------------------------------------------------------------------------
And here is how it works:
>>> text = '''defgefabcdefyuuuu
effwerbyuuuterrfr'''
>>> import SE
>>> String_Editor = SE.SE ( 'abcdef=highway defgef=news effwer=monitor')
>>> print String_Editor (text)
newshighwayyuuuu
monitorbyuuuterrfr
----------------------------------------------------------------------------------
----- Original Message -----
From: "f pemberton" <fpemberton133 at yahoo.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Saturday, August 12, 2006 6:49 PM
Subject: trouble with replace
> I have a string (xdata) and theres a newline after every 17 characters
> of the string. I was wondering how I can replace multiple substrings
> multiple times within a string? To put it another way, this is what i
> want to do.
>
> Substring to find ("abcdef") replace it with ("highway")
> search again, substring to find ("defgef") replace it with
> ("news").Search again and find ("effwer") replace it with
> ("monitor").Example string to search under is '''defgefabcdefyuuuu
>
>
> effwerbyuuuterrfr'''
>
> I've tried using replace but its not working for me.
> xdata.replace('abcdef', 'highway')
> xdata.replace('defgef', 'news')
> xdata.replace('effwer', 'monitor')
> Basically I would want to get the output of "newshighwayyuuuu
>
>
> monitorbyuuuterrfr"
>
> Thanks, any help would be appreciated.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list