Change captured values in a regexp

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 #<MatchData “Oct 22 06:25:35” 1:“22” 2:“06:25:35”>
It should return #<MatchData “Oct 22 06:25:35” 1:“22” 2:“03:25:35”>

On Oct 26, 8:47am, Bruno S. [email protected] wrote:

Instead of #<MatchData “Oct 22 06:25:35” 1:“22” 2:“06:25:35”>
It should return #<MatchData “Oct 22 06:25:35” 1:“22” 2:“03:25:35”>


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)
==>#<DateTime: 42430529827/17280,0,2299161>
t.strftime(“%b %d %H:%M:%S”)
==>“Sep 30 23:25:35”

On Tue, Oct 26, 2010 at 4:47 PM, Bruno S. [email protected] wrote:

Instead of #<MatchData “Oct 22 06:25:35” 1:“22” 2:“06:25:35”>
It should return #<MatchData “Oct 22 06:25:35” 1:“22” 2:“03:25:35”>

That’s not a job for regular expressions. You need to handle this by
yourself. Once you have the hour match, convert it into a Time object
(see class Time - RDoc Documentation) and then
offset it as you need.

HTH,
Ammar

On 26.10.2010 15:47, Bruno S. wrote:

It should return #<MatchData “Oct 22 06:25:35” 1:“22” 2:“03:25:35”>
You don’t want to mess with what the regexp match returns. Rather you
need to process results afterwards. And please also consider the other
comments.

Kind regards

robert