import re class Solution: # s, pattern都是字符串 def match(self, s, pattern): # write code here #pattern = '^[a-z]*(\.[a-z]*)?[a-z]*$' a='^'+pattern+'$' if re.match( a ,s, re.M|re.I): return True return False