import re
'''
以^开头,以$结尾
'''
beginWithHello = re.compile(r'^Hello')
beginWithHello.search('Hello World')
print(beginWithHello.search('He said Hello')==None)
endWithNumber = re.compile(r'\d$')
endWithNumber.search('1234567890')
print(endWithNumber.search('12 34567890 ')==None)
结果是:
True
True
网友评论