def get_search_regex(query, ignore_case=True):
 regex_text = [char for char in query if (char != ' ')]
 regex_text = '.*'.join(regex_text)
 regex = '({0})'.format(regex_text)
 if ignore_case:
  pattern = re.compile(regex, re.IGNORECASE)
 else:
  pattern = re.compile(regex)
 return pattern

def get_search_regex ( query , ignore_case = True ) : regex_text = [ char for char in query if ( char != ' ' ) ] regex_text = '.*' . join ( regex_text ) regex = '({0})' . format ( regex_text ) if ignore_case : pattern = re . compile ( regex , re . IGNORECASE ) else : pattern = re . compile ( regex ) return pattern
returns a compiled regex pattern to search for query letters in order .