:%s/.\{-}\ze\d\+,\d\+$//
This command works by binding to numbers separated by commas at the end of the line, so it works even if everything else except these numbers in the line changes .
The visual block is probably the easiest solution and one that I would use. But this will not work if the lines were to be staggered, as in:
2010-04-07 14: 25: 50,772 DEBUG This is a debug log statement - 9.8
2010-04-07 14: 25: 50,772 DEBUG This is another debug log statement - 9.8
The demimeter may also change to another character, so the line will look like this:
2010-04-07 14:25:50,772 DEBUG This is a debug log statement | 9,8
Then use :%s/.* - // will not work.
Explanation for regex:
.\{-} matches anyone except translation lines, as little as possible
\ze stops matching, so replacing does not affect the following characters
\d\+,\d\+$ digits, at least one followed by a comma, followed by at least one digits, and the end of the line
Naturally, this does not work if the format of the desired values ββat the end of the line is unstable, in which case other solutions work if the lines before the values ββhave the same length or the delimiters are the same.
Heikki naski
source share