Robert Dober
2/2/2008 10:05:00 PM
On Feb 2, 2008 7:27 PM, Corey Haines <coreyhaines@gmail.com> wrote:
> Elegant? I don't know, but I kind of like it. :)
>
> "corey".split(//).partition { |x| "aeiouAEIOU"[x] }
>
> returns
>
> => [["o", "e"], ["c", "r", "y"]]
>
> irb(main):006:0> "corey haines".split(//).partition { |x| "aeiouAEIOU"[x] }
> => [["o", "e", "a", "i", "e"], ["c", "r", "y", " ", "h", "n", "s"]]
>
> you might want to skip spaces
>
>
> -Corey
Excellent Corey, allow me to make it fit *any* string, I still have
not seen any statement that we are treating letters only ;)
"cor4ey ha2ines".scan(/[a-z]/i).join.each_char.partition { |x| "aeiouAEIOU"[x] }
Robert
---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein