Python3 正则表达式 | 菜鸟教程 http://www.runoob.com/python3/python3-reg-expressions.html
Python 正则表达式入门(初级篇) - 唯心不易 - 博客园 https://www.cnblogs.com/chuxiuhong/p/5885073.html
python正则表达式详解 - Mr.Dolphin - 博客园 https://www.cnblogs.com/dyfblog/p/5880728.html
a=self.lineEdit_personid.text() re_ex1=re.compile(r'\d+') re_ex2=re.compile(r'\D+', re.M|re.X) re_ex3=re.compile(r'\S*') a2="" b1="" b3="" if re.findall(re_ex1, a): a1=re.findall(re_ex1, a) for i in range(len(a1)): a2+=a1[i] print(a2) if re.findall(re_ex2, a): b=re.findall(re_ex2, a)#去数字 for i in range(len(b)): b1+=b[i]#列表连接字符串 # print("b1:", b1) b2=re.findall(re_ex3, b1)#新串去空 for i in range(len(b2)): b3+=b2[i]#生成非空串 print(b3)