正则1|正则2|… 写一个正则匹配一个字符串匹配123abc和456abc
re_str = r'123abc|456abc' print(fullmatch(re_str,'456abc'))写一个正则匹配一个字符串匹配123abc和456abc
re_str = r'(123|456)abc' print(fullmatch(re_str,'123abc'))两个数字两个字母的结构重复4次:
re_str = r'(\d{2}[a-zA-Z]{2}){4}'\数字 - 重复前面第M个分组匹配到的内容
re_str1 = r'(\d\d)=\1abc' print(fullmatch(re_str1,'12=12abc')) re_str = r'(\d\d)-([a-z]{3})-\2-\1' print(fullmatch(re_str,'12-abc-abc-12'))