Python regex: how to replace each instance of an occurrence with a different value?
Question: Suppose I have this string: `s = "blah blah blah"`

Using Python regex, how can I replace each instance of "blah" with a different
value (e.g. I have a list of values `v = ("1", "2", "3")`


Answer: You could use a [`re.sub`
callback](http://docs.python.org/library/re.html#re.sub):

    
    
    import re
    def callback(match):
        return next(callback.v)
    callback.v=iter(('1','2','3'))
    
    s = "blah blah blah"
    print(re.sub(r'blah',callback,s))
    

yields

    
    
    1 2 3
    

