Answer to Question #333028 in Python for String matching

Question #333028

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




1
Expert's answer
2022-04-24T17:16:21-0400


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?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS