str="status 2xx"
str="status 2xx,3xx"
str="status 2xx,3xx,4xx"
str="status blahblahblah" # should not match this
import re
if re.match('status\s+(\dxx)',str):
print "TRUE" # This matches only first condition.
我如何得到所有这些数字(2xx or 3xx or 4xx or all
),这是在文本状态后出现? 还是有其他方法来提取这些序列?如何在正则表达式中分组模式?
我们可以在正则表达式中处理像([2xx | 3xx | 4xx])吗?这可能不正确,但有人帮助我。
@Gurman:在你的例子中,第三壳体仅具有2个模式。我可以在一个组中提取所有这些序列吗? –
感谢downvoting。但问题不正确还是不可回答? –
你的问题可能会更清楚。 你是什么意思(2xx或3xx或4xx或全部)? –