使用Python来做正则表达式:
import re
txt = "It is rainy and thundering outside!"
#Check if the string contains "a" followed by 0 or more "x" characters:
y = re.findall("ax*", txt)
print('Use * character: ',y)
if y:
print("Yes, there is at least one match!")
else:
print("No match")
x = re.findall("f", txt)
print(x)
if x:
print("Yes")
else:
print("No")
z = re.findall('a', txt)
print('Only use findall() function: ',z)
使用 * 符号:zero or more occurrences
结果如下:
如果觉得不错,就点赞或者关注或者留言~~
谢谢~