Il giorno 06/nov/06, alle ore 10:35, Robert Klemme ha scritto:

> >> ansistr = "\e[31mred,\e[32;1m\e[32;1mbold green\e[33;32;31mred  
> anyway, still bold\e[33;32;31m"
> => "\e[31mred,\e[32;1m\e[32;1mbold green\e[33;32;31mred anyway,  
> still bold\e[33;32;31m"
>
> >> ansistr.split(%r{(\e\[\d+(?:;\d+)*m)}).inject([]) do |arr, s|
> ?>   case s
> >>     when ""
> >>       arr
> >>     when %r{^\e}
> >>       arr.concat( s.scan( /\d+/ ).map {|x| x.to_i} )
> >>     else
> ?>       arr << s
> >>   end
> >> end
> => [31, "red,", 32, 1, 32, 1, "bold green", 33, 32, 31, "red  
> anyway, still bold", 33, 32, 31]
>
> Kind regards
>
> 	robert

Cool!
Thanks :D