首页 > 代码库 > pyqt 正则表达式例子学习

pyqt 正则表达式例子学习

def rex01(self):

        username=QtCore.QRegExp(‘[a-zA-Z0-9_]{2,10}‘)

        self.names.setValidator(QtGui.QRegExpValidator(username,self))

        mainname=QtCore.QRegExp("^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$")

        self.mains.setValidator(QtGui.QRegExpValidator(mainname,self))

        pooh=QtCore.QRegExp(‘[0-9]{11}|[\d]{,4}-[\d]{,8}‘)

        self.poohs.setValidator(QtGui.QRegExpValidator(pooh,self))

        names=QtCore.QRegExp("[^\d]+[^\u4E00-\u9FA5]*[\d]+([^\u4E00-\u9FA5]\d*)*")

        self.addrs.setValidator(QtGui.QRegExpValidator(names,self))