K
Kenosis
Greetings friends,
I wondering if anyone here has some Ruby-fu they can share with WRT
for following problem. I've toyed with this today and don't like my
solution so I thought I'd run it by y'all. In summary, suppose we
have the following input, say to a command line interpreter:
foo bar "baz 42" "matz ruby yarv" jruby
Running split on this string, of course, yeilds:
['foo', 'bar', '"baz', '42"', '"matz', 'ruby', 'yarv"', 'jruby']
What I'd like instead is a "split" that respects the quoted word
groupings, which would result in the following instead:
['foo', 'bar', 'baz 42', 'matz ruby yarv', 'jruby']
Thanks in advance for any ideas you can lend!
Cheers,
Ken
I wondering if anyone here has some Ruby-fu they can share with WRT
for following problem. I've toyed with this today and don't like my
solution so I thought I'd run it by y'all. In summary, suppose we
have the following input, say to a command line interpreter:
foo bar "baz 42" "matz ruby yarv" jruby
Running split on this string, of course, yeilds:
['foo', 'bar', '"baz', '42"', '"matz', 'ruby', 'yarv"', 'jruby']
What I'd like instead is a "split" that respects the quoted word
groupings, which would result in the following instead:
['foo', 'bar', 'baz 42', 'matz ruby yarv', 'jruby']
Thanks in advance for any ideas you can lend!
Cheers,
Ken