
正则表达式
妙舞汉宫人
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python 正则表达式(2)
import re text="Hi,I am Shirley Hilton.I am his wife." m=re.findall(r"i.",text) #['i,', 'ir', 'il', 'is', 'if'] if m: print m else: print 'not match' print '---------' n=re.findall(r"i.\b",原创 2016-08-05 15:02:32 · 338 阅读 · 0 评论 -
Python 正则表达式(2)作业
#匹配出所有s开头,e结尾的单词。 import re text="site sea sue sweet see case sse ssee loses" m=re.findall(r"\bs\S*e\b",text) # [site,sue,see,sse,ssee] if m: print m else: print 'not match'原创 2016-08-05 15:10:06 · 838 阅读 · 0 评论 -
Python 正则表达式(3)匹配手机号
#匹配手机号 import re text="s127 3628391387 17648372936 183930627 1g82732973 28649703767" m=re.findall(r"1\d{10}",text) if m: print m else: print 'not match'结果: ['17648372936'] 匹配手机号,转载 2016-08-05 15:20:54 · 19070 阅读 · 3 评论 -
Python 正则表达式(4)
1.我们已经了解了正则表达式中的一些特殊符号,如\b、\d、.、\S等等。这些具有特殊意义的专用字符被称作“元字符”。常用的元字符还有: \w - 匹配字母或数字或下划线或汉字(我试验下了,发现3.x版本可以匹配汉字,但2.x版本不可以) \s - 匹配任意的空白符 ^ - 匹配字符串的开始 $ - 匹配字符串的结束 2.\S其实就是\s的反义,任意不是空白符的字符。同理,还有:转载 2016-08-05 15:51:53 · 464 阅读 · 0 评论 -
Python 正则表达式(5)电话号匹配
#写一个正则表达式,能匹配出多种格式的电话号码,包括 #(021)88776543 010-55667890 02584453362 0571 66345673 #\(?0\d{2,3}[) -]?\d{7,8} import re text="(021)88776543 010-55667890 02584533622 057184720483 837922740" m=re.findal转载 2016-08-08 08:50:16 · 10847 阅读 · 4 评论