OdarR: > how would you do a clever find and replace, where the value replacing > the tag is changing on each occurence ? > ".......TAG............TAG................TAG..........TAG....." > is replaced by this : > ".......REPL01............REPL02................REPL03..........REPL04..."
You may use something like this (tested) replacing XXXXXXXXXXXX with the correct re function: import re def replacer(mobj): replacer.counter += 1 return "REPL%02d" % replacer.counter replacer.counter = 0 print re.XXXXXXXXXXXX("TAG", replacer, s1) (If you have more than 99 replacements it will use more than two digits.) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list