Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def splitstring(string):
- """
- >>> string = 'apple orange "banana tree" green'
- >>> splitstring(string)
- ['apple', 'orange', 'green', '"banana tree"']
- """
- import re
- p = re.compile(r'"[w ]+"')
- quoted_item = p.search(string).group()
- newstring = p.sub('', string)
- return newstring.split() + [quoted_item]
Add Comment
Please, Sign In to add comment