Abstracted get_search_regex for future testing

To prepare for speed comparison with #1483, I've abstracted a `get_search_regex` method.