使用python来做正则表达式:
import re
txt = "+ - * / % ?"
#Check if the string has any + characters:
x = re.findall("[+]", txt)
print('找x的结果:',x)
if x:
print("Yes, there is at least one match!")
else:
print("No match")
y = re.findall("[?]", txt)
print('找y的结果:',y)
In sets, +, *, ., |, (), $,{} has no special meaning, so [+] means: return a match for any + character in the string
结果如下:
如果觉得不错,就点赞或者关注或者留言~
谢谢~