I am working with lines like this
[6268:1434][2023-07-17T03:44:08]i001: Burn v3.14.0.4118, Windows v10.0 (Build 22631: Service Pack 0), path: C:\Users\david\AppData\Local\Temp\{95942D14-E274-486C-A7FB-EDAF9E773422}\.cr\winsdksetup.exe
[6268:1434][2023-07-17T03:44:08]i009: Command Line: '-burn.clean.room=E:\Downloads\winsdksetup.exe -burn.filehandle.attached=728 -burn.filehandle.self=740'
For search I use
"(.*)2023-07-17(.*): "
The Double Quotes just show the string being used and with Regular Expression selected. That works.
If I then want to replace that with two blank characters.
Should be
Burn v3.14.0.4118, Windows v10.0 (Build 22631: Service Pack 0), path: C:\Users\david\AppData\Local\Temp\{95942D14-E274-486C-A7FB-EDAF9E773422}\.cr\winsdksetup.exe
getting
C:\Users\david\AppData\Local\Temp\{95942D14-E274-486C-A7FB-EDAF9E773422}\.cr\winsdksetup.exe
Should be
Command Line: '-burn.clean.room=E:\Downloads\winsdksetup.exe -burn.filehandle.attached=728 -burn.filehandle.self=740'
getting
'-burn.clean.room=E:\Downloads\winsdksetup.exe -burn.filehandle.attached=728 -burn.filehandle.self=740'
Why is the first ": " not being used as the search delimiter instead of the Last?
Why is the first ": " not being used as the search delimiter instead of the Last?
That is because the .*
regex matches the longest sequence that allows the rest of the regex to match. That is, .*
is "greedy" by default. You have two options:
Switch to a non-greedy match: .*?
. See https://www.boost.org/doc/libs/1_80_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html.
Change the second .*
to match the maximal number of non-colon characters: [^:]*
.