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 很 ...
随机推荐
- html a标签打开邮件
<a href="mailto:frotech@foxmail.com" target="_blank">frotech@foxmail.com&l ...
- JSP简单练习-数组应用实例
<%@ page contentType="text/html; charset=gb2312" %> <html> <body> <% ...
- char图表
首先看一下chart图表相应的各个属性: 要想使用chart图表,首先须要安装MSChart.exe:安装完后,工具箱里仍然没有,此时要在web.Config文件中加入以下代码: <span s ...
- python-文件压缩和解压
import tarfile #压缩 tar = tarfile.open('your.tar','w') tar.add('ooo.xml',arcname='ooo.xml') tar.close ...
- .NET 4.0 兼容 .NET 2.0 的方法
使用.net开发桌面应用,广大亲门最头疼的莫过于客户端部署的问题.基于.net 2.0 的winfrom程序因为 Framework 的分发包大小为20M左右还好解决,不幸的是如果项目中使用了Wcf, ...
- 当chm文档点击左侧,右侧无内容时的解决方案
右击chm文件->属性->安全选项卡,选择你登陆计算机的用户名,把权限改成完全控制就可以显示了
- 从blob字段读取图片 在浏览器显示
public byte[] GetProImg(string JID) { byte[] Buffer = null; using (OracleConnection conn = new Oracl ...
- java Math.random()随机数的产生
Math.random()是java内置产生随机数的函数,Math.random()能够产生[0,1)的浮点数,当我们要产生特定范围的数时,可以采用如下办法: 1.Math.random()*(最大数 ...
- C++新式类型转换
C++的四种强制类型转换,所以C++不是类型安全的.分别为:static_cast , dynamic_cast , const_cast , reinterpret_cast 新类型的强制转换可以提 ...
- 管理员权限dropfiles和copydata小时失败问题
//处理低权限向高权限进程发消息的失败的问题 if(windows::version::instance()->IsVistaOrLater()) { typedef BOOL (WINAPI ...