Regex search for multiple strings, collecting complete line on which they appear
top of page

Regex search for multiple strings, collecting complete line on which they appear


Here's a demonstration of a RegEx search run in the grep utility, Power Grep, that will collect the complete line of text that any one of multiple search terms appears on.

In this regex search the strings are separated with pipes "|" and strings of multiple words are enclosed with quotes.

^.*\b("Information Governance".*|Identification.*|Preservation|Collection.*)\b.*$

In PowerGrep set the Action Type to 'Collect Data'. Do not filter files and do not section files. The search type should be set to 'Regular Expression'.

In the Collect box enter '\0' to get the results of the search then %FILENAME% (preceded by a delimiter like a ~) so the names of the source files are included in the collected text.

Be sure to have line breaks between collected text, and save the results to a single file. Make it a .csv file.

The resulting file can be separated into two columns in Excel, and you'll be able to easily parse out the data.


bottom of page