Regex change time value after midnight

I have an application log with timestamps from 01-24 (instead of 00-23), I'm trying to search and replace "24" with "00", for example

15.03.2012 24:59:58 - SIRENG INFO  com.app.funnction.info
15.03.2012 01:01:02 - SIRENG INFO  com.app.funnction.moreinfo

Gotta come back

15.03.2012 00:59:58 - SIRENG INFO  com.app.funnction.info
15.03.2012 01:01:02 - SIRENG INFO  com.app.funnction.moreinfo

While i have

([0-9+]+).([0-9]+).([0-9\.$]+) ([0-9]+):([0-9]+):([0-9]+)

+3
source share
1 answer

Find this regex

([0-9]+\.[0-9]+\.[0-9]{4}) 24:([0-9]+:[0-9]+)

or if abbreviated character classes are supported by your regex engine, you can use this regex

(\d\d\.\d\d\.\d{4}) 24:(\d\d:\d\d)

and replace it with

$1 00:$2
  • $ 1 = first group: ([0-9]+\.[0-9]+\.[0-9]{4})will match15.03.2012
  • $ 2 = second group: ([0-9]+:[0-9]+)will match59:58
+1
source

All Articles