import re
a = "AB01"
m = re.compile(r"([A-Z]{2})(\s?_?\s?)([0-9]{2})") # note raw string
g = m.match(a)
if g:
g = m.match(a).group(1) + "-" + m.search(a).group(3)
print m.match(a).group()
print m.match(a).group(0)
print (m.match(a).group(0) == m.match(a).group())
print g
在上面的代码,是基团m.match(a).group()
的整个匹配,是相同m.match(a).group(0)
?如果是这样,哪个是首选用途?正则表达式匹配组(0)和组()相同吗?
要么提出您的问题或不要,请停止对冲的第一句话。 – jonrsharpe