RegEx (20) -使用字符 \Z (大写)

使用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

结果如下:
RegEx (20) -使用字符 \Z (大写)
如果觉得不错,就点赞或者关注或者留言~
谢谢~

上一篇:正则表达式(总结篇)


下一篇:C#遍历正则匹配到的多个结果的代码