其他分享
首页 > 其他分享> > RegEx (20) -使用字符 \Z (大写)

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,No,大写,re,print,wfs,txt,match
来源: https://blog.csdn.net/BSCHN123/article/details/112303028