regex to change time value past midnight [closed]
Question
I've an application log whith timestamps from 01-24 (instead of 00-23), I'm trying to do a search and replace "24" with "00" eg
15.03.2012 24:59:58 - SIRENG INFO com.app.funnction.info
15.03.2012 01:01:02 - SIRENG INFO com.app.funnction.moreinfo
Should return
15.03.2012 00:59:58 - SIRENG INFO com.app.funnction.info
15.03.2012 01:01:02 - SIRENG INFO com.app.funnction.moreinfo
So far i've got
([0-9+]+).([0-9]+).([0-9\.$]+) ([0-9]+):([0-9]+):([0-9]+)
Solution
Search for this regex
([0-9]+\.[0-9]+\.[0-9]{4}) 24:([0-9]+:[0-9]+)
or if shorthand 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow