From: ara.t.howard@... Date: 2007-03-02T01:06:51+09:00 Subject: Re: printf inside a string On Fri, 2 Mar 2007, James Edward Gray II wrote: > On Mar 1, 2007, at 9:39 AM, Peter Bailey wrote: > >> Hi, >> This is a pretty simple question. I need to do a "printf" of some >> numbers inside a string. I just can't figure out how to express a long >> string that has that "printf" inside it, because the printf statement >> itself has quotes, too. I just need the number to end up being >> zero-padded to 3 characters. So, for "3," I want "003." >> >> number = "3" >> >> puts "stuff, printf "%.3d\n", #{number}" > >>> printf "stuff, %.3d\n", number > stuff, 003 > => nil > > Hope that helps. alternatively puts "stuff, #{ '%.3d' % number }" -a -- be kind whenever possible... it is always possible. - the dalai lama