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. vue-cli 脚手架总结

    > vue-cli 的脚手架项目模板有browserify 和 webpack , 现在自己在用的是webpack , 官网给出了两个模板: webpack-simple 和 webpack 两 ...

  2. git 学习笔记一

    1.git的 介绍 分布式和 集中式 集中式版本控制系统最大的毛病就是必须联网才能工作,如果在局域网内还好,带宽够大,速度够快,可如果在互联网上,遇到网速慢的话,可能提交一个10M的文件就需要5分钟, ...

  3. Win7x64安装Oracle11201x64 解决PLSQL Developer无法找到oci问题

    http://blog.sina.com.cn/s/blog_4c7628c40101cf56.html http://blog.csdn.net/shenkxiao/article/details/ ...

  4. (转)web.config详解之在文件中配置网站默认页面

    在<configuration></configuration>中添加下面的配置 <system.webServer>        <defaultDocu ...

  5. Js弹性漂浮广告代码

    <html><head><meta http-equiv="Content-Type" content="text/html; charse ...

  6. C#调用C++的DLL 数据类型转换

    /C++中的DLL函数原型为        //extern "C" __declspec(dllexport) bool 方法名一(const char* 变量名1, unsig ...

  7. Visual Studio/vs2013 正忙

    打开VS解决方案时一直显示Visual Studio正忙,项目卡在初始化,此后试了很多方法,将项目拷贝到领一个磁盘当中再打开就可以直接打开了

  8. 0130——UIScrollView

    1.contentSize幕布实际大小决定滚动的方向,如果小于图片本身不滚动,默认也是不滚动 view.contentSize = CGSizeMake(1280, 200); 而frame只是用来显 ...

  9. 定义block块

    一: 工程图 二: 代码区 AppDelegate.h #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <U ...

  10. OD调试学习笔记7—去除未注册版软件的使用次数限制

    OD调试学习笔记7—去除未注册版软件的使用次数限制 本节使用的软件链接 (想自己试验下的可以下载) 一:破解的思路 仔细观察一个程序,我们会发现,无论在怎么加密,无论加密哪里,这个程序加密的目的就是需 ...