Issue with regular expressions

Julien jphalip at gmail.com
Tue Apr 29 09:46:05 EDT 2008


Hi,

I'm fairly new in Python and I haven't used the regular expressions
enough to be able to achieve what I want.
I'd like to select terms in a string, so I can then do a search in my
database.

query = '   "  some words"  with and "without    quotes   "  '
p = re.compile(magic_regular_expression)   $ <--- the magic happens
m = p.match(query)

I'd like m.groups() to return:
('some words', 'with', 'and', 'without quotes')

Is that achievable with a single regular expression, and if so, what
would it be?

Any help would be much appreciated.

Thanks!!

Julien



More information about the Python-list mailing list