"Mauricio FernŠŌdez" <batsman.geo / yahoo.com> schrieb im Newsbeitrag
news:20040206212618.GA9696 / student.ei.uni-stuttgart.de...
> On Sat, Feb 07, 2004 at 04:50:21AM +0900, Bermejo, Rodrigo wrote:
> > Dear Ruby List:
> >
> > I'm trying to add one hr, to some time strings:
> >
> > "1:12:00" --> "2:12:00"  (i don't need to worry about 24)
> >
> > Mi first try was ...
> >
> > "1:12:00".gsub(/(^\d?\w)/,$1.to_i.succ.to_s)
>
> "1:12:00".gsub(/(^\d?\w)/) { $1.to_i.succ.to_s }

I'd prefer a solution that works without a global variable:

"1:12:00".gsub(/^\d+/) {|m| m.to_i.succ}

Regards

    robert