CradonWar
CradonWar

Reputation: 21

How do I remove starting and ending parts of strings for each line in Notepad++

I have a list of timestamps containing only one timestamp on each line like 00:06:29:14 which follows as: hours, minutes, seconds, and milliseconds. Now, I want to delete hours and milliseconds to get only the minutes and seconds like 06:29 from this certain list.

On Notepad++ I find ^[^:]+:(.+)$ replacing all with $1 in Regular expression Search Mode, which gives me the result of only removing the hours part at the beginning.

I need a single code to both delete hours at the beginning and milliseconds at the end of each line to save a great chunk of my time to work smart. Any ideas?

Upvotes: 0

Views: 588

Answers (1)

The fourth bird
The fourth bird

Reputation: 163277

You can make the match a bit more specific and replace with group 1

^\d{2}:(\d{2}:\d{2}):\d+$

Regex demo

enter image description here

Or matching the hours, minutes and seconds:

^(?:[01]?\d|2[0-3]):([0-5]?\d:[0-5]?\d):\d+$

Regex demo

Upvotes: 1

Related Questions