re. help needed :(
Dan Bishop
danb_83 at yahoo.com
Fri Feb 22 19:22:42 EST 2002
More information about the Python-list mailing list
Fri Feb 22 19:22:42 EST 2002
- Previous message (by thread): re. help needed :(
- Next message (by thread): Request for comments: Search and replace script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"G. Willoughby" <sab at NOSPAM.freeuk.com> wrote in message news:<a56838$qb8$1 at newsg4.svr.pol.co.uk>... > Hi, > Im trying to replace the single word "lamb" and the word lamb followed > by any punctuation in this string: > > x="Mary had a little lamb called lamb, but didn't like the lamb's mood" > > i want to replace all of the single words "lamb[punctuation]" but not the > word "lamb's" to achieve this: > > x="Mary had a little pig called pig, but didn't like the lamb's mood" > > any help with be greatly appreiciated! Here's one way: x = x.replace("lamb's", "XspamX").replace("lamb", "pig").replace("XspamX", "lamb's")
- Previous message (by thread): re. help needed :(
- Next message (by thread): Request for comments: Search and replace script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list