From: Brian Candler Date: 2007-05-04T16:48:41+09:00 Subject: Re: Is there a better way to do this? On Fri, May 04, 2007 at 04:42:31PM +0900, Brian Candler wrote: > Actually, you could bend sprintf to do the former too: > > val = "1234567890" > fmt = "(000) 000-0000" > res = sprintf(fmt.gsub(/0/,"%s"), *val.split(//)) which of course can be shrunk to val = "1234567890" fmt = "(000) 000-0000" res = fmt.gsub(/0/,"%s") % val.split(//)