我是正则表达式的新手,使用 python re 我希望从下面的多行字符串文本中提取电话号码:
Source = """<p><strong>Kuala Lumpur</strong><strong>:</strong> +60 (0)3 2723 7900</p>
<p><strong>Mutiara Damansara:</strong> +60 (0)3 2723 7900</p>
<p><strong>Penang:</strong> + 60 (0)4 255 9000</p>
<h2>Where we are </h2>
<strong> Call us on:</strong> +6 (03) 8924 8686
</p></div><div class="sys_two">
<h3 class="parentSchool">General enquiries</h3><p style="FONT-SIZE: 11px">
<strong> Call us on:</strong> +6 (03) 8924 8000
+ 60 (7) 268-6200 <br />
Fax:<br />
+60 (7) 228-6202<br />
Phone:</strong><strong style="color: #f00">+601-4228-8055</strong>"""
所以当我编译模式时,我应该能够找到使用
phone = re.findall(pattern,source,re.DOTALL)
['+60 (0)3 2723 7900',
'+60 (0)3 2723 7900',
'+ 60 (0)4 255 9000',
'+6 (03) 8924 8686',
'+6 (03) 8924 8000',
'+ 60 (7) 268-6200',
'+60 (7) 228-6202',
'+601-4228-8055']
请帮我确定正确的模式
原文由 Shekhar Samanta 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用
re
模块。