Daniel Schierbeck wrote:

> My problem is that I have a string like this: "3:foo6:monkey5:sheep", 
> which I need to separate into ["foo", "monkey", "sheep"]. The values can 
> contain numeric values, so splitting at \d won't work. This is what 
> makes it difficult:
> 
>   "3:ab23:cat5:sheep" => ["ab2", "cat", "sheep"]
> 
> I need to grab the number, then read that many characters, then read the 
> next number, etc.

"3:foo6:monkey5:sheep".scan(/(\d+)\:([^\d]+)/){|(num,str)|
     if num.to_i == str.length
         # correct
     else
         # not correct
     end
}

lopex