Find and Replace
Level 10 users can use Content > Find and Replace to search through files (and some reusable content) and replace content. After seeing a list of results, you can choose which ones to replace. Find and replace searches the content of files, including source code, but not file names.
Use caution when performing a global find and replace. Page templates and other resource files can be affected if they are included in the search scope.
Search CriteriaLink to this section
When you open Find and Replace, the first screen is the "Options" and "Scope" panels.
Under "Options," define what you're searching for.
- Type: If you choose "Literal Text," the find and replace looks for the text string that you enter in the "Find" field. Choosing "Regular Expression" tells the find and replace to look for any text that matches the regex string you enter in the "Find" field.
- Find: Enter the text or regular expression to search for.
- The use of leading, trailing, or mid-string spaces are honored when performing a literal text find and replace action. For example, searching for " d" would return the results " do" and " dog" but not "and."
- Ignore Case: Check this to ignore the case of the text you're searching for.
- Replace With: If you are going to do a replace, enter the text you want to replace the found content with. If you perform a replace with nothing in the "Replace With" field, the found content is deleted.
Under "Scope," determine which areas of your site you're searching.
- Include Assets: Select to include web content, source code, and plain text assets in your search.
- Include Components: Select to search the content of a component that has been placed on a page. Does not search component source code.
- Exclude Checked-Out Files: Select to exclude checked out pages, files, and assets from your search, including those in a workflow or with a scheduled action like a publish or expire.
- File Extensions: You can choose to exclude certain file extensions from your search, or only search for files with certain extensions. Specify extensions either by typing into the field, or by clicking and selecting from the dropdown. For no restrictions, select "Exclude these extensions" and leave the field blank.
- Files and Folders: Select the files and folders you want to search. The top checkbox selects/deselects all files and folders in the site.
Then, depending on what you want to do, select either Find or Preview Replace.
After running a find, the results are shown. The summary at the top gives some basic information about the results, including the total number of matches and how many files contain a match.
Underneath, each file containing a match is listed, with the number of matches and the line in the source code that contains the match, and the matching text highlighted in blue. The number of results at the top refers to the number of files with matches, not the total number of matches.
ReplaceLink to this section
After running a replace, all potential replace matches are shown. The summary at the top shows information about the find and replace, including the total number of matches and how many files contain a match.
Underneath, each file containing a match is listed, with the number of matches and the line in the source code that contains the match. The existing match content is in red, with the potential replacement in green. This is a preview of the potential replace actions.
Select which files you would like to replace the content on. If a file is selected, all the matches on that page are replaced; there is no ability to pick which specific matches are replaced.
Once you've selected which files you want to replace, click Replace. Enter a version description, and click Replace again. The content on the selected pages is replaced, and a version of each file saved.
Now you see a summary of the files that had content replaced. Select those files and choose to either revert the replace or publish them to push the changes to the live website. If a file can't be published, such as if it's checked out, the status is marked as "Error."
Last Replace Results
If you navigate to Find and Replace before running a find or replace, you can choose "Last Replace Results" from the left menu. This shows the results of the last find and replace that was performed, by any user. You can revert the replace or republish the files.
If a file has a newer version than the one saved by the replace, the version number is in red. Reverting that file to before the replace would revert it to that version, and undo any other changes made after the replace. Therefore any pages with a newer version have revert disabled.
However, you can enable revert for all files by clicking Enable Revert For All Files. Click on the version number to see a preview of the version you'll reverting the page to. Revert the files to the version number indicated.