WoNáDo
3/16/2007 2:07:00 PM
James Edward Gray II schrieb:
> On Mar 16, 2007, at 8:51 AM, Satish Talim wrote:
>
>> On 3/16/07, Andrew Stewart <boss@airbladesoftware.com> wrote:
>>>
>>> Hello,
>>>
>>> What's a (good) way to convert this:
>>>
>>> 'a quick "brown fox" jumped "over the lazy" dog'
>>>
>>> into this:
>>>
>>> [ 'a', 'quick', 'brown fox', 'jumped', 'over the lazy', 'dog' ] ?
>>>
>>> Thanks!
>>>
>>> Regards,
>>> Andy Stewart
>>>
>>
>> Do this -
>> 'a quick "brown fox" jumped "over the lazy" dog'.split
>
> Not quite the same. Look again. ;)
>
> James Edward Gray II
>
But this works:
irb(main):001:0> 'a quick "brown fox" jumped "over the lazy" dog'.split(/[ "]+/)
=> ["a", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"]
Wolfgang Nádasi-Donner