This post originated from an RSS feed registered with Ruby Buzz
by Mike Naberezny.
Original Post: Parsing Quoted Strings in Ruby
Feed Title: MikeNaberezny.com
Feed URL: http://mikenaberezny.com/category/ruby/feed/
Feed Description: Mike Naberezny blogs about Ruby, Rails, and other dynamic language topics.
Python has a nice module in the standard library called shlex that parses strings as a Unix shell would. Here's a Python interpreter session demonstrating its usage:
>>> import shlex
>>> shlex.split('foo "bar baz" qux')
['foo', 'bar baz', 'qux']
It's useful for creating your own mini-languages or external DSLs that need to parse ...