python正则匹配示例

text="山东省临沂市兰山区 市委大院中区21号楼4单元 276002 奥特曼1号 18254998111"

#匹配手机号
m=re.findall(r"1d{10}",text)
if m:
    print(m)

#匹配电话号
pattern = re.compile(r"((d{3}|(d{3})|d{4}|(d{4}))?(s|-|.)?(d{8}))")
a = re.match(pattern, text)
if a:
    print(a.group())
#正则替换
text = re.sub(r'转收|收|:|手机号|电话号|手机|电话|收件人', '', text)

#查找
match_list = re.findall(u'广告位|广告点位', text)
原文地址:https://www.cnblogs.com/ying-chease/p/10723563.html