By what method would a string be inserted at each instance of a RegEx match?
For example: string = '123 abc 456 def 789 ghi' newstring = ' INSERT 123 abc INSERT 456 def INSERT 789 ghi' Here's the code I started with: >>> rePatt = re.compile('\d+\s') >>> iterator = rePatt.finditer(string) >>> count = 0 >>> for match in iterator: if count < 1: print string[0:match.start()] + ' INSERT ' + string[match.start ():match.end()] elif count >= 1: print ' INSERT ' + string[match.start():match.end()] count = count + 1 My code returns an empty string. I'm new to Python, but I'm finding it really enjoyable (with the exception of this challenging puzzle). Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list