RegEx (11) - 使用字元 \A
阿新 • • 發佈:2021-01-08
使用python來做正則表示式:
import re
txt = "The the t the th"
#Check if the string starts with "The":
x = re.findall("\AThe", txt)
print('\AThe 結果:',x)
if x:
print("Yes, there is a match!")
else:
print("No match")
#Check if the string starts with "t":
y = re.findall("\At", txt)
print('\At 結果:',y)
字元 \A: Returns a match if the specified characters are at the beginning of the string.
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~