使用python来做正则表达式:
import re
txt = "324 sd 4d ! ?"
#Check if the string has any white space:
x = re.findall("[ ]", txt)
print(x)
if x:
print("Yes, there is at least one match!")
else:
print("No match")
y = re.findall("[! ?]", txt)
print(y)
if y:
print("Yes, there is at least one match for ! and ? and white space")
else:
print("No match!")
使用字符 [arn]: Returns a match where one of the specified characters (a, r, or n) are present
结果如下:
如果觉得不错,就点赞或者关注或者留言~
谢谢~