RegEx (20) -使用字元 \Z (大寫)
阿新 • • 發佈:2021-01-17
使用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
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~