Notepad++ how to extract only the text field which is needed?

爱⌒轻易说出口 提交于 2019-12-13 20:12:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!