Do Python regexes support something like Perl's \G?
Question: I have a Perl regular expression (shown
[here](http://stackoverflow.com/questions/529657/how-do-i-write-a-regex-that-
performs-multiple-substitutions-on-each-line-except/529735#529735), though
understanding the whole thing isn't hopefully necessary to answering this
question) that contains the \G metacharacter. I'd like to translate it into
Python, but Python doesn't appear to support \G. What can I do?


Answer: Try these:

    
    
    import re
    re.sub()
    re.findall()
    re.finditer()
    

for example:

    
    
    # Finds all words of length 3 or 4
    s = "the quick brown fox jumped over the lazy dogs."
    print re.findall(r'\b\w{3,4}\b', s)
    
    # prints ['the','fox','over','the','lazy','dogs']
    

