Forum: Ruby nuby: %w to understand quotes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2006-04-22 07:51
(Received via mailing list)
Hi All,

irb(main):007:0> %w{this is a test}
=> ["this", "is", "a", "test"]


irb(main):008:0> %w{"this is" "a test"}
=> ["\"this", "is\"", "\"a", "test\""]

i want

["this is","a test"]

Is there a ruby notation like %w that understand quotes?

thank you and kind regards -botp
49ab3ce5a4922b4747d1d6f330784629?d=identicon&s=25 Jake McArthur (Guest)
on 2006-04-22 08:04
(Received via mailing list)
Try this:

%w{this\ is a\ test}

- Jake McArthur
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2006-04-22 08:07
(Received via mailing list)

In message "Re: nuby: %w to understand quotes"
    on Sat, 22 Apr 2006 14:48:46 +0900, Peña, Botp <>

|irb(main):008:0> %w{"this is" "a test"}
|=> ["\"this", "is\"", "\"a", "test\""]
|i want
|["this is","a test"]
|Is there a ruby notation like %w that understand quotes?

%w understands backslash escape

|irb(main):001:0> %w{this\ is a\ test}
|=> ["this is","a test"]

This topic is locked and can not be replied to.