Pattern-match & Replace - help required
Thomas Bach
thbach at students.uni-mainz.de
Wed Dec 19 06:27:19 EST 2012
More information about the Python-list mailing list
Wed Dec 19 06:27:19 EST 2012
- Previous message (by thread): Pattern-match & Replace - help required
- Next message (by thread): Pattern-match & Replace - help required
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote:
> Hi,
>
> I am new to python and web2py framework. Need urgent help to match a
> pattern in an string and replace the matched text.
>
Well, what about str.replace then?
>>> 'egg, ham, tomato'.replace('ham', 'spam, ham, spam')
'egg, spam, ham, spam, tomato'
If the pattern you want to match is more complicated, have a look at
the re module!
Regards,
Thomas.
- Previous message (by thread): Pattern-match & Replace - help required
- Next message (by thread): Pattern-match & Replace - help required
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list