code: def prep_search_string(cls, search_string, match_substrings):
          
          if sys.version < '3' and not isinstance(search_string, unicode):
              search_string = search_string.decode('utf-8')
          s = search_string.strip()
          # we don't want stars from user
          s = s.replace('*', '')
          if len(s) < _get_config(cls)['search_string_min_len']:
              raise ValueError('Search string must have at least 3 characters')
          # replace multiple with star space star
          if match_substrings:
              s = u'*{0}*'.format(re.sub('[\s]+', '* *', s))
          # TODO: some sanitization
          return s
docs: Prepares search string as a proper whoosh search string.
  
          :param search_string: The search string which should be prepared.
          :param match_substrings: ``True`` if you want to match substrings,
                                   ``False`` otherwise.