Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
re solution in Clear category for Unix Match. Part 1 by andreyihnatchenko
import re
def unix_match(filename: str, pattern: str) -> bool:
pattern_re = ''
for i in pattern:
if i == '*':
pattern_re += '.+'
elif i == '?':
pattern_re += '.'
else:
pattern_re += '[' + i + ']'
if re.findall(pattern_re, filename):
return True
return False
July 21, 2020
Comments: