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))
#正则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 正则表达式例子学习的更多相关文章
- pyqt QTreeWidget例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt columnView例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt QTableView例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt QTableWidget例子学习(重点)
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...
- pyqt 托盘例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...
- pyqt tabWidget例子学习1
from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...
- pyqt 配置文件例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys,datetime from PyQt4.QtC ...
- pyqt 自定义例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore impor ...
- 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇
http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...
随机推荐
- Object-c学习之路十二(OC的copy)
oc中的拷贝分为:copy(浅拷贝)和mutablecopy(深拷贝). 浅拷贝也为指针拷贝,拷贝后原来的对象计数器会+1: 深拷贝为对象拷贝,原来的对象计数器不变. 注意:自定义对象拷贝时要实现NS ...
- Mybatis分页插件PageHelper正确的用法(网上有2篇不够科学的文章)
今天下午在Mybatis项目中.实现分页.由于我是后加入项目中的,Leader用的是PageHelper这个组件.可是我在实际使用的过程中遇到了2个大问题. 1.p=2#comments" ...
- Codeforces 468B Two Sets 并查集
题目大意:给出n个数,要求将n个数分配到两个集合中,集合0中的元素x,要求A-x也再0中,同理1集合. 写了几个版本号,一直WA在第8组数据...最后參考下ans,写了并查集过了 学到:1.注意离散的 ...
- VSIM生成fsdb波形文件(VERILOG)
VSIM生成fsdb波形文件(verilog) 两步主要的设置 testbench加入函数 运行库调用 1.testbench加入函数 initial begin $fsdbDumpfile(&quo ...
- HTML与CSS入门——第十二章 在网页中使用多媒体
知识点: 1.如何链接多媒体文件 2.如何嵌入多媒体文件 3.使用多媒体的更多技巧 多媒体文件:音频,视频和动画,以及静态的图像和文本. 这里我就直接讲HTML5了…… 此前都是用ojbect来加载或 ...
- ASP.NET中实现Ajax分页
在页面中指定一个div容器来接收动态生成的分页数据: <div id="div_menu"> </div> 使用jQuery来请求并处理Json格式数据: ...
- Activity-在ListFragment中为ListView增加空白视图
有两种方法可以实现为ListView添加空白视图.但是原理都一样: 第一种方法是XML+代码添加: 1.定义emptyView视图 2.调用AdapterView的setEmptyView(empt ...
- 全世界最详细的图形化VMware中linux环境下oracle安装(二)【weber出品必属精品】
<ORACLE 10.2.05版本的升级补丁安装> 首先我们解压 $ unzip p8202632_10205_LINUX.zip 解压后我们会发现多出了个文件夹,他是:Disk1,进入D ...
- gridView 布局间距合理化的有效办法
网上有很多人闻到过这个问题,给出好多办法,多数人并不是意见提的不对,而是没有抓住问题的本质 . 因为我要做一个girdView的demo实例,遇到了这个问题 与大家一起分享,如果有想要demo的请给我 ...
- hdu4006 优先队列
A - 签到 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65768KB 64bit I ...