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:

  1. Select the files you want to list matches from in the File Selector.
  2. Start with a fresh action.
  3. Set the action type to “collect data”. Leave the search type as “regular expression”.
  4. Enter the regular expression that matches the items you want to collect. Use capturing groups to extract specific parts of each record.
  5. 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.
  6. 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.
  7. 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.
  8. 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”.