def equal(s1, s2): for i in range(len(s1)): if s1[i] == '?' or s1[i] == s2[i]: continue else: return False return True def find(sub, idx, s2): while len(s2) - idx >= len(sub): if equal(sub, s2[idx:idx+len(sub)]): return idx else: idx += 1 return -1 while True: try: s1 = input() s2 = input() lst1 = list(s1) # 1、以*号为分隔符,将它们分隔为多个子串 lst1 = [seg for seg in "".join(lst1).split('*') if seg] # 2、到s2中去寻找这些子串,如果它们都是按照现后顺序在s2出现的,则能匹配成功 idx = 0 flag = 0 for sub in lst1: rst = find(sub, idx, s2) if rst != -1: idx = rst + len(sub) else: print("false") flag = 1 break if not flag: print("true") except: break