Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
re.match(pattern, string) solution in Clear category for Unix Match. Part 3 by David_Jones
import re
def unix_match(filename, pattern):
regex = pattern
for old, new in zip('. * ? [! [[] []] [.] [.*]'.split(),
'\. .* . [^ \[ \] \? \*'.split()):
regex = regex.replace(old, new)
try:
return bool(re.match(regex, filename))
except re.error:
return filename == pattern
June 15, 2019
Comments: