1
0
mirror of https://github.com/wting/autojump synced 2026-03-02 03:49:26 +00:00

Add match_anywhere tests.

This commit is contained in:
William Ting
2016-05-04 00:50:47 -07:00
parent cf013c6875
commit 3cb4e8a28c
2 changed files with 72 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ def match_anywhere(needles, haystack, ignore_case=False):
(path='/foo/baz', weight=10),
]
"""
regex_needle = '.*' + '.*'.join(needles).replace('\\', '\\\\') + '.*'
regex_needle = '.*' + '.*'.join(imap(re.escape, needles)) + '.*'
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
found = lambda haystack: re.search(
regex_needle,