问题
I have a log file which has lot of data. But it would be in similar format.
Sample text:
Line 1428: [errormessage] = 21:26:07.629 acceptance criteria not met. Expected:0.0009999871, Actual:0.007407427, Window:[0.007407427] at Hello.TestAutomation.Tests.Implementation.TestExecution.MirrorTestExecutor.b__12_1(IMonitor m, MonitoringEventArgs e) Line 1429: [errormessage] = 21:26:07.629 acceptance criteria not met. Expected:0.0009999871, Actual:0.007407427, Window:[0.007407787] at Hello.TestAutomation.Tests.Implementation.TestExecution.MirrorTestExecutor.b__12_1(IMonitor m, MonitoringEventArgs e)
Now i want to filter text after Window: which is in [ ]: ex for Line 1428, I only need 0.007407427 / [0.007407427] which ever is easy and respectively from the whole log file.
Expected output:
0.007407427
0.007407787
Any suggestions? I found a regular expression to detect what i want [([0-9,.]*?)] but how to replace all the other text and only leave this text left.
Thanks in advance.
回答1:
Use capture groups. Assuming there is only one window per line:
Find field: ^.+Window:\[([0-9,\.]+).+
Replace field: \1
来源:https://stackoverflow.com/questions/45092473/notepad-how-to-extract-only-the-text-field-which-is-needed