,
, , , " " " " ( | "" ).
, RE ( - ), , (), , ().
'.*?'.join(list_patterns) ( RE), , '.*?'.join(re.escape(p) for p list_patterns)).
, , , . (, itertools.permutations), '.*?' | - RE , N N! ( "N " - , N 4, 4 * 3 * 2 * 1 == 24). , , , , , .
" " ( ), , , RE - , RE relist=[re.compile(p) for p in list_patterns] " s, " all(r.search(s) for r in relist) .
, " " RE, , , , , search, ( " " ):
class relike(object):
def __init__(self, list_patterns):
self.relist = [re.compile(p) for p in list_patterns]
def search(self, s):
return all(r.search(s) for r in relist)
source
share