"Simon Strandgaard" <0bz63fz3m1qt3001 / sneakemail.com> schrieb im
Newsbeitrag news:pan.2003.06.24.11.06.57.495092 / sneakemail.com...
> On Tue, 24 Jun 2003 20:45:43 +0900, Rob wrote:
>
> > I am having a problem with regular expression.
>
> Have you tried String#split  ?
>
> > irb
> irb(main):001:0> s = "oranges apples bananas"
> => "oranges apples bananas"
> irb(main):002:0> s.split(/ /)
> => ["oranges", "apples", "bananas"]
> irb(main):003:0>

That's the negative approach (btw: I'd prefer to use /\s+/ instead of / /
because it's safer).  A positive approach could be

irb(main):001:0> s = "oranges apples bananas"
"oranges apples bananas"
irb(main):002:0> s.scan /\w+/
["oranges", "apples", "bananas"]
irb(main):003:0>

As always, there's a lot of roads to the target... :-)

    robert