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))

#正则1和2

def TextRe(self):

re1=QRegExp('[\w_]{6,20}')

self.mailEdit_2.setValidator(QRegExpValidator(re1,self))

self.re2=QRegExp('(pop|smtp)*[a-zA-Z.]*[\d]{3,7}[.](com|com.cn|cn)$')

self.mailEdit.setValidator(QRegExpValidator(self.re2,self))

def _text2(self):

import string as s

text1=s.letters

text=self.mailEdit_2.text()

if text.isEmpty():

self.Prompt_2.setText(u'邮箱地址不能为空')

else:

if len(text)<6:

self.Prompt_2.setText(u'邮箱地址长度小于6')

else:

self.Prompt_2.setText(u'邮箱地址合法')

if unicode(text)[0] not in text1:

self.Prompt_2.setText(u'邮箱地址必须以字母开头')

#需要正则

def _text1(self):

text=self.mailEdit.text()

if text.isEmpty():

self.Prompt.setText(u'邮箱服务器不能为空')

else:

pop1='pop|smtp'

import re

match=re.search(pop1,unicode(text))

if not match:

self.Prompt.setText(u'必须以pop|smtp开头')

else:

if len(text)<10:

self.Prompt.setText(u'长度过小')

else:

self.Prompt.setText(u'邮箱服务器合法')

补充内容

匹配普遍意义的url

^(https?://)?([\da-z\.-]+)\.([a-z\.]{2,6})([/\w \.-]*)*/?$

匹配cn的url

^(https?://)?([\da-z\.-]+)\.cn([/\w \.-]*)*/?$

匹配google.cn的url

^(https?://)?google\.cn([/\w \.-]*)*/?$

网址:http://segmentfault.com/q/1010000000135951

pyqt 正则表达式例子学习的更多相关文章

  1. pyqt QTreeWidget例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  2. pyqt columnView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  3. pyqt QTableView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  4. pyqt QTableWidget例子学习(重点)

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  5. pyqt 托盘例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  6. pyqt tabWidget例子学习1

    from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...

  7. pyqt 配置文件例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys,datetime from PyQt4.QtC ...

  8. pyqt 自定义例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore impor ...

  9. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

随机推荐

  1. Win32/MFC的基本概念

    一.MFC的基本概念 单文档.多文档和对话框框架的区别 MFC中的类继承图的基本框架 CView类与CDocument的关系 Onpaint()和Ondraw()的关系 hdc-cdc区别联系 RUN ...

  2. 获取文本区域(textarea)行数【换行获取输入用户名个数】

    需求:输入会员名,一行一个,最多可输入1000个 效果:

  3. NoSQL 数据库的使用场景

    摘要:对比传统关系型数据库,NoSQL有着更为复杂的分类——键值.面向文档.列存储.图数据库.这里就带你一览NoSQL各种类型的适用场景及一些知名公司的方案选择. 在过去几年,关系型数据库一直是数据持 ...

  4. Oracle 用户、对象权限、系统权限

    --================================ --Oracle 用户.对象权限.系统权限 --================================  一.用户与模式 ...

  5. javascript监听事件兼容

    function addEvent(el ,type ,fn){ if(el.addEventListener){ el.addEventListener(type,fn,false); }else ...

  6. BULK INSERT如何将大量数据高效地导入SQL Server

    转载自:http://database.51cto.com/art/201108/282631.htm BULK INSERT如何将大量数据高效地导入SQL Server 本文我们详细介绍了BULK ...

  7. Opencv 函数

    1.cvLoadImage:将图像文件加载至内存: 2.cvNamedWindow:在屏幕上创建一个窗口: 3.cvShowImage:在一个已创建好的窗口中显示图像: 4.cvWaitKey:使程序 ...

  8. Python爬虫——抓取贴吧帖子

    抓取百度贴吧帖子 按照这个学习教程,一步一步写出来,中间遇到很多的问题,一一列举 首先, 获得 标题 和 贴子总数 # -*- coding:utf-8 -*- #!/user/bin/python ...

  9. win8(64位)下memcache安装时报错“ failed to install service or service already installed” 与安装

    解决办法: 1.找到cmd.exe文件(c:\windows\system32\cmd.exe) 2.右键cmd.exe以管理员方式运行 3.把php_memcache.dll放到php的ext目录: ...

  10. Scala学习笔记--集合类型Queue,Set

    补充知识:http://www.importnew.com/4543.html 正文开始 scala.collection.immutable scala.collection.mutable 队列Q ...