String matching
Input 1
3
Hello Hell*
Hell He*ll
Hell hell*
Output 1
True
False
Input 2
Hello *l?
Hell He? ll
Hell ? *
Output 2
import re def mtch(): try: st, reg = input().split() reg = reg.replace("*", ".*") ans = re.search(reg, st) if (ans): print(True) else: print(False) except: print(False) n=int(input()) for i in range(n): mtch()
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments