My stab at it:
My stab at it:
#!/usr/bin/env python
import re
query = ' " some words" with and "without quotes " '
query = re.sub("\s+", " ", query)
words = []
while query.__len__():
query = query.strip()
print("Current query value: '%s'" % query)
print words
print
if query[0] == '"':
secondQuote = query[1:].index('"') + 2
words.append(query[0:secondQuote].replace('"', '').strip())
query = query[secondQuote:]
else:
if query.count(" ") == 0 :
words.append(query)
query = ""
else:
space = query.index(" ")
words.append(query[0:space])
query = query[space:]
print words
print query
--
http://mail.python.org/mailman/listinfo/python-list