Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for search_regex_function
This can be used to generate regex to limit the search query to substring within the menu entries. e.g. A menu entries may be defined as [ " 1 : menu A : 2024/09/18", " 2 : menu B : 2024/09/17", " 3 : menu C : 2024/09/19", ... "10 : menu J : 2023/09/10" ] If I want to limit the search to just the serial number, I can change the search string '2' to regex '^2', so that it does not match '2'024. For this, I can provide an optional parameter search_regex_function defined as: def my_search_regex_function(text): if re.match('[0-9][0-9]*$', text) and int(text) < len(menu_items): text = f'^ *{text}(?= : )' return re.compile(text, flags=re.IGNORECASE) With above function, 2 will only match menu B. 2024 will match all menu entries. The function itself can be customized for individual requirements.
- Loading branch information