# 元字符+,*遇到?后就会变为贪婪匹配 print(re.findall('abc+?','abcccccc')) #['abc'] print(re.findall('abc*?','abcccccc')) #['ab'] print(re.findall('abc{1,4}','abcccabc')) #['abccc', 'abc'] print(re.findall('abc{1,4}?','abcccabc')) #['abcc', 'abc'] #--------------------------------------------------------------------- #元字符之字符集[] print(re.findall("[abc]","sdfgbahjkkk")) #若是字符集的前后没有字母,就会分别匹配a,b,c ['b', 'a'],否在就字符集里选择一个字母和外面的连接使用 print(re.findall("a[a-z]","fwefaefewaasfwe")) #['ae', 'aa'] print(re.findall("a[.*+]","a.b*c+")) #在字符集里的符号就是普通符号 ['a.'] print(re.findall("[^ab]","fgddab")) #['f', 'g', 'd', 'd'] print(re.findall("[1-9]","vsd1fdv2sdvsd23")) #['1', '2', '2', '3'] print(re.findall("d[1-9]","vsd1fdv2sdvsd23")) #['d1', 'd2'] print(re.findall("[\d]","af1fsdf2ffsf1")) #['1', '2', '1'] print(re.findall("[1-9]","af1fsdf2ffsf1")) #['1', '2', '1']