Python 正则表达式或 [英] Python regular expressions OR
本文介绍了Python 正则表达式或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我想要一个同时匹配从我的 iPhone 发送"和从我的 iPod 发送"的正则表达式.我怎么写这样的表达?
Suppose I want a regular expression that matches both "Sent from my iPhone" and "Sent from my iPod". How do I write such an expression?
我尝试了以下方法:
re.compile("Sent from my [iPhone]|[iPod]")
但似乎不起作用.
推荐答案
re.compile("Sent from my (iPhone|iPod)")
这篇关于Python 正则表达式或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文