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. java获取项目地址或tomcat绝对地址

    在java项目中获取文件的路径,不管是相对路径还是绝对路径,其本质都是通过绝对路径去寻找. 获取项目地址 request.getSession().getServletContext().getRea ...

  2. Button和ImageButton

    Button----button ImageButton----图片button 共同拥有特征: 都能够作为一个button产生点击事件 不同点 1. Button有text的属性.ImageButt ...

  3. unity3d 学习笔记(一)

    操作:按下shit 点击坐标轴中心 切换透视图 动画烘焙的概念:相当于把原来的控制器动画或者IK(骨骼)动画所有塌陷为逐帧动画,导出的时候必须选这一项 着色器:从技术的角度来看,着色器是渲染器的一个部 ...

  4. JavaScripts学习日记——BOM

    IE 3.0 和 Netscape Navigator 3.0 提供了一种特性 - BOM(浏览器对象模型),可以对浏览器窗口进行访问和操作.使用 BOM,开发者可以移动窗口.改变状态栏中的文本以及执 ...

  5. .NET基础拾遗(6)特性

    1 神马是特性?如何自定义一个特性? (1)特性是什么     特性是一个对象,可以加载到程序集及程序集的对象中,这些对象包括 程序集本身.模块.类.接口.结构.构造函数.方法.方法参数等,加载了特性 ...

  6. Java中关于OOM的场景及解决方法

    原文地址:http://developer.51cto.com/art/201112/305696.htm 1.OOM for Heap=>例如:java.lang.OutOfMemoryErr ...

  7. 错误记录--更改tomcat端口号方法,Several ports (8005, 8080, 8009)

    启动Tomcat服务器报错: Several ports (8005, 8080, 8009) required by Tomcat v5.5 Server at localhost are alre ...

  8. iOS图片拉伸技巧—— resizableImageWithCapInsets

    http://blog.csdn.net/chaoyuan899/article/details/19811889

  9. ADO.NET中连接SQL Sever

    1.在配置文件中定义数据库连接信息. 在配置文件*.config中添加这段代码在<configuration>与</configuration>之间: <connecti ...

  10. [QT]QT概述

    QT概述 基于C++的GUI开发框架,跨平台.Qt 是一个用于桌面系统和嵌入式开发的跨平台应用程序框架. QT是挪威TROLLTECH公司开发的跨平台C++工具,在UNIX下非常出名:他的宗旨是“一次 ...