Collect a Numbered List
Using a "collect data" action with match placeholders makes it easy to create all kinds of numbered lists. You could create a simple numbered list of all search matches as follows:
- Select the files you want to list matches from in the File Selector.
- Start with a fresh action.
- Set the action type to "collect data". Leave the search type as "regular expression".
- Enter the regular expression that matches the items you want to collect. Use capturing groups to extract specific parts of each record.
- As the text to be collected, enter %MATCHN%. \0. %MATCHN% is a placeholder for the number of the match. \0 is a backreference to the entire regex match.
- Set the target type to "save results into a single file" to output all search matches as one long list in a single file. If you choose to save one file for each searched file, you'll probably want to use %MATCHFILEN% instead of %MATCHN% in the text to be collected, so the numbering starts from 1 in each file.
- Leave "between collected text" set to "Line break". PowerGREP will insert a line break between each collected match. PowerGREP will not insert it before the first match or after the last match.
- Click the Collect button to create the numbered list.
You can find this action in the PowerGREP5.pgl standard library as "Collect a numbered list".