The basic way to use PowerGREP’s search and replace functionality is like the search and replace feature offered by any text editor. Type in the text you want to have replaced in the search box. Put the text you want to have it replaced with in the Replace box. Specify the folder and file mask (such as *.txt), and click the Execute button. PowerGREP will then perform the search and replace operation on all files matching the file mask in the folder that you specified, and in its subfolders if you want.
But PowerGREP offers you much more than that. If you want, PowerGREP will present you with a list of all replacements that have been made. Double-click on a replacement to see its context. Prevent mistakes by previewing the results before modifying any files. Replace or revert individual matches in PowerGREP’s full-featured file editor. Should you change your mind later, the Undo History will save your day by restoring all files that were modified.
Specify target options to tell PowerGREP to duplicate the files searched through and make the replacements in the duplicated files. This way you can easily produce different editions of the same set of files.
Powerful Text File Maintenance with Regular Expressions
While searching and replacing pieces of text is useful, you can automate many tedious editing tasks by adding regular expressions to the mix. Let me present you with an example. Suppose you have a rather long list of pairs in the form of one=another and you want to swap them. You can do this easily with PowerGREP by searching with the regular expression (\w+)=(\w+) and replacing with \2=\1. The regular expression will match a word, followed by an equals sign, followed by another word. The parenthesis capture the first word into the first “backreference”, and the second word into the second “backreference”. In the replacement text, we can reuse those with \1 and \2 respectively. So setting the replacement text to \2=\1 will swap the words.
Do not worry if the above looks complex. The documentation that is included with PowerGREP contains a detailed introduction to regular expressions. With a bit of practice, you can create simple regular expressions like the above in a matter of minutes. And when you spend time creating a complex regular expression, you can save it into a PowerGREP action file or library for instant reuse later.
Redact Files with Search and Delete
A search-and-delete is like a search-and-replace with a blank replacement. You can use it to easily redact a list of items. You can also use it to de-duplicate file content by deleting only duplicate matches.
Edit MS Word and OpenOffice Documents
PowerGREP’s built-in converters for MS Word DOCX files and OpenOffice and LibreOffice ODT files allow you to search and replace through these files. In the File Selector, make sure “file formats to convert to plain text” is set to “writable proprietary formats” or “all writeable formats”. Substituted text will retain its formatting, even though PowerGREP doesn’t show you any formatting.
“The first thing I tried [after upgrading to PowerGREP 5] was a find-and-replace within an MS Word document. It worked perfectly in a Hebrew right-to-left document! For me this is the most dramatic, long-awaited achievement, allowing, at last, a decent find-and-replace feature to replace [MS Word’s] nonsensical “wild card” built-in feature. Many thanks, again, for a fantastic, must-have product!”
— Motti Teicher
9 September 2016, Israel
“I am working with my version of PowerGREP for some time now, and I really enjoy every single time where I am much faster doing complicated search&replace sessions on different files. Some people really can’t believe until they see what PowerGREP is capable of. Thanks for creating it.”
— Andreas Kroll
23 July 2008, Germany
“PowerGREP is quite simply the best search and replace tool I have ever tried. Hands Down. No Contest.”
— Lorne Guse
21 December 2004, Canada