def get_query_words(query):
 word_finder = re.compile(u'"([^"]+)"|(\\S+)').findall
 normalize_spaces = re.compile(u'\\s{2,}').sub
 words = []
 for word in word_finder(query):
  found_word = (word[0] or word[1])
  words.append(normalize_spaces(u' ', found_word.strip()))
 return words

def get_query_words ( query ) : word_finder = re . compile ( u'"([^"]+)"|(\\S+)' ) . findall normalize_spaces = re . compile ( u'\\s{2,}' ) . sub words = [ ] for word in word_finder ( query ) : found_word = ( word [ 0 ] or word [ 1 ] ) words . append ( normalize_spaces ( u' ' , found_word . strip ( ) ) ) return words
get query words split the query into words and return a list of strings .