Hi --

On Sat, 16 Aug 2003, Dan Doel wrote:

> Ooo! I know, what about:
>
> re = /((?@<numbers>\d+)|(?@<words>\w+)\s?)+/
> m = re.match("1234 hello 56 what are you doing 98")
> m['numbers'] #=> ["1234", "56", "98"]
> m['words'] #=> ["hello", "what", "are", "you", "doing"]
>
> Is there an alternate solution to that that doesn't use multiple regexps?

I can't think of one -- but I can think of a solution I like a lot
anyway :-)  It makes use of the new Enumerable#partition:

  words,numbers = str.scan(/\d+|\w+/).partition {|e| /\D/.match(e) }


David

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav