Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
translate to re solution in Clear category for Unix Match. Part 2 by juestr
import re
def unix_match(filename: str, pattern: str) -> bool:
try:
p = re.escape(pattern) \
.replace(r'\[!', r'[^').replace(r'\[', r'[') \
.replace(r'\]', r']').replace(r'[^]', r'\[!\]')
return re.fullmatch(p, filename) is not None
except re.error:
return False
Aug. 6, 2021
Comments: