Python正则表达式是否支持像Perl的\ G?

mik*_*ike 5 python regex perl

我有一个Perl正则表达式(在这里显示,虽然理解整个事情不是必须回答这个问题)包含\ G元字符.我想将它翻译成Python,但Python似乎不支持\ G. 我能做什么?

Tri*_*ych 4

试试这些:

import re
re.sub()
re.findall()
re.finditer()
Run Code Online (Sandbox Code Playgroud)

例如:

# 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']
Run Code Online (Sandbox Code Playgroud)