使用python来做正则表达式:
import re
txt = "xcv xfr wfs"
#Check if the string ends with "wfs":
x = re.findall("wfs\Z", txt)
print(x)
if x:
print("Yes, there is a match!")
else:
print("No match")
txt_new = "234 2432 sw 543 sdfsd"
y = re.findall("sdf\Z", txt_new)
print(y)
if y:
print("Yes, there is a match!")
else:
print("No match")
字符 \Z: Returns a match if the specified characters are at the end of the string
结果如下:
如果觉得不错,就点赞或者关注或者留言~
谢谢~