On Feb 4, 10:51 am, "Emanuele D'Arrigo" <man...@gmail.com> wrote: > Hi everybody, > > I'm having a ball with the power of regular expression
Don't forget the ball you can have with the power of ordinary Python strings, string methods, and string interpolation! originalString = "spam:%(first)s ham:%(second)s" print originalString % { "first" : "foo" , "second" : "" } prints spam:foo ham: with far fewer surprises and false steps. (Note: Py3K supports this same feature, but with different interpolation syntax, which I have not learned yet.) Book recommendation: Text Processing in Python, by David Mertz (free online - http://gnosis.cx/TPiP/), in which David advises against dragging out the RE heavy artillery until you've at least thought about using ordinary string methods. -- Paul -- http://mail.python.org/mailman/listinfo/python-list