re.match和re.search的区别

re.match(pattern, string, flags)    #Only beginning of the string
re.search(pattern, string, flags)    #Searches everywhere of the string
import re

string = 'python crash course'
m = re.match('y', string)
print("Matching result: ", m)

s = re.search('y', string)
print("Searching result: ", s)

 

posted @ 2020-03-03 14:52  Lovange  阅读(149)  评论(0)    收藏  举报