Quote-aware string splitting
- From: "J. W. McCall" <jmccall@xxxxxxxxxxxxxx>
- Date: Tue, 26 Apr 2005 01:23:17 GMT
Hello,
I need to split a string as per string.strip(), but with a modification: I want it to recognize quoted strings and return them as one list item, regardless of any whitespace within the quoted string.
For example, given the string:
'spam "the life of brian" 42'
I'd want it to return:
['spam', 'the life of brian', '42']
I see no standard library function to do this, so what would be the most simple way to achieve this? This should be simple, but I must be tired as I'm not currently able to think of an elegant way to do this.
Any ideas?
Thanks,
J. W. McCall .
- Follow-Ups:
- Re: Quote-aware string splitting
- From: Paul McGuire
- Re: Quote-aware string splitting
- From: Jeffrey Froman
- Re: Quote-aware string splitting
- From: Tim Heaney
- Re: Quote-aware string splitting
- Prev by Date: Re: Python documentation moronicities (continued)
- Next by Date: Re: Do I need a nested lambda to do this?
- Previous by thread: Pythonic way to do static local variables?
- Next by thread: Re: Quote-aware string splitting
- Index(es):