import sys
import re
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
arr=test.split()
regex=""
for c in arr[0]:
if c == '.':
regex += '\.'
elif c == '?':
regex +='.'
elif c == '*':
regex +='.*'
else:
regex +=c
sol=[]
for x in range(1,len(arr)):
if re.match('^'+regex+'$', arr[x]):
sol.append(arr[x])
value=""
for i in range(len(sol)):
if i>0 :
value += " "
value += sol[i]
if not value:
value = "-"
print value
test_cases.close()
import re
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
arr=test.split()
regex=""
for c in arr[0]:
if c == '.':
regex += '\.'
elif c == '?':
regex +='.'
elif c == '*':
regex +='.*'
else:
regex +=c
sol=[]
for x in range(1,len(arr)):
if re.match('^'+regex+'$', arr[x]):
sol.append(arr[x])
value=""
for i in range(len(sol)):
if i>0 :
value += " "
value += sol[i]
if not value:
value = "-"
print value
test_cases.close()
No comments:
Post a Comment