Robert Klemme wrote: > > If there is a fixed number of formats you can probably use a cascade of > RX matches. Unfortunately not. > Otherwise it probably becomes a bit more complex like > matching sequences of digits and measuring their lengths. > > >> md = %r{^(\d+)\.(\d+)?$}.match('0.4577') > => #<MatchData:0x7ef61250> > >> pa="%#{md[0].size}.#{md[2].size}f" Hmmm, this looks like a viable path. I hadn't thought of using MatchData groups, but as you say, it may get ugly fast... I'm thinking of edge cases like dealing with the leading space if positive numbers become negative, or accommodating the number of digits needed for exponentials or integers if the new number exceeds the capacity of the existing format. Thanks, -- Bil Kleb http://fun3d.larc.nasa.gov