From: James Edward Gray II Date: 2007-09-28T09:08:31+09:00 Subject: Re: Break apart a string by kind of characters On Sep 27, 2007, at 7:05 PM, Daniel Waite wrote: > Gavin Kistner wrote: >> irb(main):001:0> s = 'a1000aa' >> => "a1000aa" >> irb(main):002:0> s.split( /(\d+)/ ) >> => ["a", "1000", "aa"] > > WOW! Freakin' awesome! > > One caveat... > > irb(main):004:0> '11aa1000aaa'.split(/(\d+)/) > => ["", "11", "aa", "1000", "aaa"] > > For some reason it answers with a blank element, but I'm sure > that's an > easy one to solve. If you just want digits and non-digits, I suggest: >> '11aa1000aaa'.scan(/\D+|\d+/) => ["11", "aa", "1000", "aaa"] James Edward Gray II