Replace HTML Tags

When editing a web site, you may want to update some HTML tags to give the site a more consistent look. Let's say some pages were created by other people, and they used slightly different text and background colors. With PowerGREP, you can easily do a search and replace to replace any <body> tag with the one you want.

  1. Select the files you want to search through in the File Selector.
  2. Make sure the file format configuration searches through the raw (unconverted) contents of HTML files. The predefined "None" configuration is one that does this.
  3. Start with a fresh action.
  4. Set the action type to "search and replace". Leave the search type as "regular expression".
  5. In the search box, enter the regular expression <BODY[^>]*> and make sure to leave "case sensitive search" off. This regular expression will match <BODY, followed by zero or more characters that aren't a closing sharp bracket, followed by a single closing sharp bracket.
  6. Type the tag you want to replace all body tags with in the Replacement box. E.g.: <BODY BGCOLOR=white TEXT=black>
  7. Set the target and backup file options as you like them.
  8. Click the Preview button to run a test.
  9. If all looks well, click the Replace button to actually replace the tags.

Maintaining your web site is much easier with the help of PowerGREP. Most (visual) HTML editors cannot do a search and replace across all files your web site consists of. Most text editors can only search and replace literal strings, which makes it tedious to replace several styles of tags with the same tag.

You can find this action in the PowerGREP5.pgl standard library as "Replace HTML tags".