主页
Python
Python 正则表达式
demo_regex
运行 ❯
×
更改方向
保存代码
更改主题
import re #Check if the string starts with "The" and ends with "Spain": txt = "The rain in Spain" x = re.search("^The.*Spain$", txt) if x: print("YES! We have a match!") else: print("No match")
YES! We have a match!