From: Corey Haines Date: 2008-02-03T07:11:08+09:00 Subject: Re: Extracting vowels and consonants using regular expression ------=_Part_459_27842983.1201990274245 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Sweet! I like pulling the numbers out, but I get this in irb irb(main):001:0> "cor4ey ha2ines".scan(/[a-z]/i).join.each_char.partition { |x| "aeiouAEIOU"[x] } NoMethodError: undefined method `each_char' for "coreyhaines":String Why not use split(//) instead of each_char? On Feb 2, 2008 5:04 PM, Robert Dober wrote: > On Feb 2, 2008 7:27 PM, Corey Haines 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 > > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ------=_Part_459_27842983.1201990274245--