
python正则表达式基础
LinBigCat
个人邮箱:
展开
-
python正则表达式(1)
import retext = "Hello,I am linheng.I am a student."matchObj1 = re.findall(r'\bhe\b',text)#表示he这个单词,结果是无匹配 if matchObj1: print(matchObj1)else: print('not match')matchObj2 = re.findall转载 2018-01-26 16:13:25 · 200 阅读 · 0 评论 -
python正则表达式,匹配电话号码
#写一个正则表达式,能匹配出多种格式的电话号码,包括:text = "(021)88776543 010-55667890 02584533622 057184720483 837922740"m = re.findall(r'\(?0\d{2,3}[)-]?\d{7,8}',text)if m: print(m)else: print('not match')结果:转载 2018-01-26 19:58:47 · 18264 阅读 · 3 评论