a.分組 - 將括號中的內(nèi)容看成一個整體
(abc){2} --> abcabc
abc{2} --> abcc
b.分組重復(fù) - 在有分組的正則表達(dá)式中误证,可以在分組后面通過'\數(shù)字'來重復(fù)前面第幾個分組匹配到的內(nèi)容
(\d{2})abc\1 --> 78abc78
"""
def main():
re_str = r'[a-z]{3}|\d{3}'
print(re.fullmatch(re_str, '384'))
re_str = r'abc([A-Z]{2}|\d{2})'
print(re.fullmatch(re_str, 'abcKD'))
re_str = r'(abc){2}'
print(re.fullmatch(re_str, 'abcabc'))
re_str = r'(\d{2})a(\d{3})bc\2{2}\1'
print(re.fullmatch(re_str, '34a890bc89089034'))