On Sep 18, 11:17 pm, Analogy Analogy <analog... / aol.com> wrote:

> [...]

> Also, ["391", "2", "0.10%]
>
> becomes ["391.0", "2.0", "0.1%]
>
> Don't want to do change/anything to the first and second items.

test = ["391", "2", "0.10%", "10.001%", "#x80C and #x670"]

test.map { |string| string.gsub(/^([+-]?[0-9]*[.][0-9]*[1-9])(0+)%$/,
'\1%') }

==> ["391", "2", "0.1%", "10.001%", "#x80C and #x670"]

better, but test it throughly,
btw, /\A([+-]?\d*[.]\d*[1-9])(0+)%\Z/ is a bit more proper.

Do you want "4%" to become "4.0%" ?

> Is there
> a good place online, to learn about this type of stuff? Thanks.

http://en.wikipedia.org/wiki/Regular_expressions

http://ruby-doc.org/core/classes/String.html#M000832

HTH

P.S I'm (total) newbie too... is there 'parse float' method ?
'to_s' imo is too poor.