Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
recursive, no regexp solution in Creative category for Unix Match. Part 1 by igor.vaiman
import re
def unix_match(filename: str, pattern: str) -> bool:
# if one of input strings is empty
if len(filename)*len(pattern)==0 :
if len(filename) == len(pattern) :
return True
else :
return False
# if both has at lest 1 character
if pattern[0]=='?' :
# just skip to next character
return unix_match(filename[1:], pattern[1:])
else :
if pattern[0]=='*':
# find closest non-command character
# while keeping track of how many '?'
# (guaranteed characters) we meet
pi = 0
fi = 0
while (pi
May 16, 2020
Comments: