From: "ara.t.howard" Date: 2007-10-28T13:12:32+09:00 Subject: Re: convert string format On Oct 27, 2007, at 5:15 PM, Junkone wrote: > Hello > I have a date like 20070801 in a string. how do i change it to > 2007/08/01 using regex > thanks > > using regexen for that's suicide unless you want to accept invalid time strings. use the functionality already provided by ruby: cfp:~ > cat a.rb require 'time' puts Time.parse('20070801').strftime('%Y/%m/%d') puts Time.parse('20070842').strftime('%Y/%m/%d') rescue puts $!.message cfp:~ > ruby a.rb 2007/08/01 argument out of range kind regards. a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama