From: w_a_x_man Date: 2010-10-26T23:50:15+09:00 Subject: Re: Change captured values in a regexp On Oct 26, 8:47 am, Bruno Sousa wrote: > Hi everyone! > Supposing there is a string like this: > Oct 22 06:25:35 machine kernel: [271182.956004] IN= OUT=eth0 > SRC=10.8.0.248 DST=192.5.5.241 > > I am using the following regexp to capture time: > /Oct (\d{2}) (\d{2}:\d{2}:\d{2})/ > > How can I alter the hour value only and keep it in the result returned? > I want to decrease 3 hours. > Instead of # > It should return  # > > -- > Posted viahttp://www.ruby-forum.com/. What is going to happen when you subtract 3 hours from a date like this: Oct 01 02:25:35 require 'date' ==>true t=DateTime.parse("Oct 01 02:25:35") - Date.time_to_day_fraction(3,0,0) ==># t.strftime("%b %d %H:%M:%S") ==>"Sep 30 23:25:35"