Output Text between 2 lines using filtering option

不想你离开。 提交于 2021-01-28 09:24:07

问题


We are using EMEditor for logfile analytics in huge textfiles. We have following requirement.
In the logfile, there are a lot of tables in this format:

+----------------------+
|Column1|Column2|Colum3|
+-------+-------+------+
|Data1  |Data2  |Data3 |
|Data4  |Data5  |Data6 |
+-------+-------+------+
| Number of Records: 2 |
+----------------------+

The text between the header and footer is very dynamic; it could be 0 or x-lines between it.

I would use the filter option in this way, that I input for example |Column1 using the start filter and | Number of Records: as end filter. EMEditor should filter all records between start- and end filter (inclusive line with the found filter patterns).

I have seen, it's currently only possible to output lines above and under the filter pattern, but this is no practicable way.

How can I achieve this?


回答1:


If + and | characters are used only for tables, you can filter tables by these characters. To do this, you can click the Advanced Filter button in the Filter toolbar, click Add button and enter +, click Add button again to enter |, and set the Logical Disjunction (OR) to the Previous Condition option to the second item in the list. Finally, click Filter button.

Updates

Download EmEditor v20.0.902 or later, and use the Begin Filter and End Filter options in the Advanced Filter.

If you would like to use a macro, this is a macro for you:

filters = document.filters;
filters.Clear();
filters.AddFind( "|Column1", eeFindReplaceCase, eeExFilterBegin );
filters.AddFind( "| Number of Records:", eeFindReplaceCase, eeExFilterEnd );
document.filters = filters;

You can run this macro after you open your data file. To do this, save this code as, for instance, Filter.jsee, and then select this file from Select... in the Macros menu. Finally, open your data file, and select Run in the Macros menu while your data file is active.




回答2:


Does this HAVE to be done via filter? Is it not possible to isolate/select just the table data using the standard Find method? e.g. Ctrl-F. Click on Advanced and make sure "Regular Expression "." can match Newline Characters is selected. Set the Additional lines to Search for RegEx to a number higher than what you expect the largest table.

Click OK and then Find (Regular Expressions Selected):

(?<=^\+----------------------\+.)\|.+?(\| Number of Records[^\|]+\|)

Click "Select All" and this should hopefully capture just the tables and you can now do what you want with it (Click the Extract button, copy, cut, etc.).



来源:https://stackoverflow.com/questions/63232259/output-text-between-2-lines-using-filtering-option

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