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 很 ...
随机推荐
- js iframe 跳转
iframe 页面内操作: //iframe指向指定页面 parent.document.getElementById("hot").src = $("#hidPageU ...
- openfire文件夹
插件开发 学习制作第一个 openfire 插件 http://www.cnblogs.com/jying/p/3683409.html 跟我一步一步开发自己的Openfire插件 http://bl ...
- 无语的index hint:手工分配哈希区,5小时不出结果,优化后20分钟
同事说,有个语句5个小时不出结果,叫我帮忙看看,于是叫同事发过来.不看不知道,一看吓一跳,3个表关联,强制使用了2个index hint,当中一个表9g,一个表67g,另一个小表40Mb.开发者,总以 ...
- Android开源代码解读のOnScrollListener实现ListView滚屏时不加载数据
使用ListView过程中,如果滚动加载数据的操作比较费时,很容易在滚屏时出现屏幕卡住的现象,一个解决的办法就是不要在滚动时加载数据,而是等到滚动停止后再进行数据的加载.这同样要实现OnScrollL ...
- 关于transform的2D
在transform的学习中,自己总结了一点经验. 我们知道transform有2D和3D的两大类变换,这里分享下关于2D的属性简单示例: 一.2D变换: (x为水平,y为垂直) 1.skew(斜拉 ...
- js Date扩展Format()函数
Date.prototype.Format = function (formatStr) { var str = formatStr; var Week = ['日', '一', '二', '三', ...
- GDI+编程的10个基本技巧(转)
创建绘图表面 创建绘图表面有两种常用的方法.下面设法得到PictureBox的绘图表面. private void Form1_Load(object sender, System.EventArgs ...
- (五)CodeMirror - 关于htmlmixed中包含script脚本
最近发现个问题,场景如下: 当创建的mode类型为htmlmixed,且内容中包含javascript脚本,且是闭包立即执行: 如果内容是使用JQuery函数.html()插入到DOM中后再创建cod ...
- 【0】Laravel 5.1 简介
1.简介 Laravel是一套简洁.优雅的PHP Web开发框架(PHP Web Framework).它可以让你从面条一样杂乱的代码中解脱出来:它可以帮你构建一个完美的网络APP,而且每行代码都可以 ...
- hprof教程
大部分内容参考http://www.linuxidc.com/Linux/2012-04/58178.htm J2SE中提供了一个简单的命令行工具来对java程序的cpu和heap进行 profili ...