On Jun 10, 2005, at 5:28 PM, Pete Elmore wrote:

> Ezra Zygmuntowicz wrote:
>
>> "SPT_051205.jpg"
>> How could I strip out the numbers that stand for the date and  
>> convert  it to look like this:
>> "May 12 2005"
>>
>
> #!/usr/bin/env ruby
> require 'date'
> def date_from_special_string(s)
>     /(\d\d)(\d\d)(\d\d)/.match s
>     month = $1
>     day = $2
>     year = "20#{$3}"
>     Date::parse("#{month}/#{day}/#{year}").strftime("%B %d %G")
> end
>
> puts date_from_special_string "SPT_051205.jpg"
>
> There was a little ambiguity in the example (Was the month the  
> first 05, or was that the year?), so you may need to swap the $1  
> and $3.
>
> Hope that was helpful.
>
> Pete
>
>
Thanks Pete, that helps a lot as well. I guess I should have picked a  
better example too. But you got it right the first 05 is the month  
and the last one was the year. I'll take care to use an unambiguous  
sample next time.

Thanks!

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra / yakima-herald.com