查看: 376|回复: 0
打印 上一主题 下一主题

[教程] powergrep 002

[复制链接]

该用户从未签到

258

主题

1651

回帖

1万

积分

状元

Rank: 9Rank: 9Rank: 9

积分
19159

灌水大神章小蜜蜂章笑傲江湖章

跳转到指定楼层
1
发表于 2017-11-18 08:52:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Action Part: Collect Between

The "search", "collect data", and "merge files" action types save search matches to one or more target files, at l** when "target file creation" is set to anything except "do not save results to file". If an action finds three matches 1, 2, and 3 you may want to save them as 1,2,3 into the target file rather than as 123. The "collect between" part of the Action panel is where you can tell PowerGREP what, if anything, PowerGREP should place between the collected matches. In this example we're putting a comma between all the matches.

In addition or instead of putting text between matches, you can add a header and footer to each target file created by PowerGREP. When collecting matches from multiple source files (files that were searched through) into a single target file, you can also add a header and footer to the blocks of matches that were found in the same source file. You can use path placeholders to add references to the files the matches were found in.

The appearance of the "collect between" part of the action changes based on what you select in the "between collected text" drop-down list and whether you tick "collect headers and footers". If you're not using any options that require custom text, no text box appears:

Collect line breaks between matches
If you're using only one delimiter between the matches without any headers or footers, you get one box to type in that delimiter:

Collect a comma between matches
If you're using multiple delimiters or headers and footers then a list with different items appears. All the items in the list are used when you execute the action. The item that you select is the one that you can edit in the text box:

Various headers, footers, and text between matches
Between Collected Text
Choose which text, if any, you want to place between text that was collected for different search matches:

Nothing: Don't put anything between text collected for different matches.
Line break: Use a separate line to collect the text for each search match.
Text between matches and files: Put the same text between all matches, regardless of which files they were collected from.
Text between matches only: Put text between the matches collected from the same file. Do not put any text between matches collected from different files (other than file headers and footers).
Text between files only: Do not put any text between matches collected from the same file. When saving text from multiple files into a single file, put text between matches collected from different files.
Different text between matches and files: Put one bit of text between text collected for matches from the same file, and another bit of text between matches collected from different files. The text to be put between matches from different files is only used when saving text from multiple files into a single file.
Collect Headers and Footers
Add a header and footer to the files into which the collected text is saved. When collecting into a single file, you can also add a header and footer to the block of text collected from each file searched through.

Expand Placeholders
Expand path placeholders as well as action-related and file-related match placeholders in file headers and footers. In source file headers and footers, path placeholders represent the path to the file that the matches were found in. In target file headers and footers, they represent the file that the collected text is written to.

The match placeholder %MATCHCOUNT% can be used in source file footers to indicate the number of matches found in each source file. %MATCHCOUNT% can be used in target file footers to indicate the number of matches written to each target file. %FILECOUNT% can be used in target file footers to indicate the number of source files that had their matches written to that target file.

Select Text to Edit
Select the text you want to edit in the edit box to the right of this list. Which matches are available depends on the choices you make for "between collected text", "collect headers and footers", and "target file creation".

Between matches: Text to be put between collected matches, whether they're from the same file or from different source files.
Between matches from the same file: Text to be put between matches collected from a single source file.
Between matches from different files: Text to be put between the blocks of matches collected from different source files, when they are being saved into a single target file.
Source file header and footer: Text to be put before and after a block of text collected from a single file. Can use path placeholders to insert the path to the source file. Used when creating a separate target file for each file, as well as when collecting text from multiple sources into a single target file.
Target file header and footer: Text to be put at the start and the end of each file created by the collect data action. Only used when collecting text from multiple source files into a single target file.
Examples: Compile indices of files and Generate a PHP navigation bar

Discuss

Start or join the conversation on the topic "Docs: Action Part: Collect Between" in PowerGREP's discussion forum.