diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 191ac53f94..998c21c50c 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -20,6 +20,7 @@ from calibre.utils.localization import (canonicalize_lang, lang_map, get_udc, from calibre.ebooks.metadata import title_sort, author_to_author_sort from calibre.ebooks.metadata.opf2 import metadata_to_opf from calibre import prints +from calibre.utils.icu import primary_find class MetadataBackup(Thread): # {{{ ''' @@ -147,9 +148,10 @@ def _match(query, value, matchkind): return True elif query == t: return True - elif ((matchkind == REGEXP_MATCH and re.search(query, t, re.I|re.UNICODE)) or ### search unanchored - (matchkind == CONTAINS_MATCH and query in t)): - return True + elif matchkind == REGEXP_MATCH: + return re.search(query, t, re.I|re.UNICODE) + elif matchkind == CONTAINS_MATCH: + return primary_find(query, t)[0] != -1 except re.error: pass return False