1. 程式人生 > 其它 >RegEx (11) - 使用字元 \A

RegEx (11) - 使用字元 \A

技術標籤:RegExpython正則表示式regex

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

結果如下:
在這裡插入圖片描述
如果覺得不錯,就點贊或者關注或者留言~
謝謝~