使用python来做regex:
import re
txt = "falls stays"
#Check if the string contains either "fall" or "stays":
x = re.findall("fall|stays", txt)
print('fall|stays 结果: ',x)
if x:
print("Yes, there is at least one match!")
else:
print("No match")
#Check if the string contains either "fall" or "stay":
y = re.findall('fall|stay', txt)
print('fall|stay 结果: ',y)
z = re.findall('fall|b', txt)
print('fall|b 结果:', z)
字符 | 意思表示:Either or
结果如下:
如果觉得不错,就点赞或者关注或者留言~
谢谢~