From: 7stud -- Date: 2007-10-28T11:55:05+09:00 Subject: Re: convert string format Brian Adkins wrote: > On Oct 27, 10:09 pm, "David A. Black" wrote: >> >> > irb(main):003:0> "20070801".unpack("a4a2a2").join("/") >> > => "2007/08/01" >> >> And here's one with scanf: >> >> >> "20070801".scanf("%4s%2s%2s").join('/') >> => "2007/08/01" > > Yeah, but scanf is implemented in Ruby, so it's 25 times slower (at > least by a crude, quick benchmark) than unpack or insert :( I was going to post that same solution, but after timing it, I almost gagged when I saw the results. -- Posted via http://www.ruby-forum.com/.