String matching
Input 1
3
Hello Hell*
Hell He*ll
Hell hell*
Output 1
True
True
False
Input 2
3
Hello *l?
Hell He? ll
Hell ? *
Output 2
True
False
True
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()
Comments
Leave a comment