From: Michael 'entropie' Trommer Date: 2006-01-07T10:55:45+09:00 Subject: Re: Splitting strings on spaces, unless inside quotes --c3bfwLpm8qysLVxt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * James Edward Gray II (james@grayproductions.net) wrote: > >> example = %Q{some words "some quoted text" some more words} > => "some words \"some quoted text\" some more words" > >> example.scan(/\s+|\w+|"[^"]*"/). > ?> reject { |token| token =~ /^\s+$/ }. > ?> map { |token| token.sub(/^"/, "").sub(/"$/, "") } > => ["some", "words", "some quoted text", "some", "more", "words"] impressive So long -- Michael 'entropie' Trommer; http://ackro.org ruby -e "0.upto((a='njduspAhnbjm/dpn').size-1){|x| a[x]-=1}; p 'mailto:'+a" --c3bfwLpm8qysLVxt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFDvx+QBBd8ye5RguQRAoXnAJ4+n/djV0bwu6mgjskyi3tBcLdGuwCgunmv UyILBLpTRU2WjSJx/53txSY= =uN3j -----END PGP SIGNATURE----- --c3bfwLpm8qysLVxt--