Apply Script Function – HTML Example
Note: This example is provided for compatibility with earlier versions of Search and Replace. Users of version 3.2+ should make use of HTML Mode. When HTML Mode is active, Search and Replace automatically handles html special characters.
This example of the Apply Script function shows how the function may be used to handle plain text equivalents of special html characters. For example, the “&” character is typically represented as “&” in raw html code. A search string of “Search & Replace©” may not make any hits on a scan of html files because the actual html code might be “Search & Replace©”. The Apply Script function can be used to process the search string itself to quickly change “&” to “&” and to “©” to “©” before doing the search.
1. Begin by creating a script to perform the transforms using the Script Dialog or manually, using a text editor. A simple html conversion script for “&” and “©” is:
[Script for Search and Replace]
[End of Search and Replace Script]
This script can be any name. The name, “html tranform example.srs“, will be used here.
2. To use html tranform example.srs in the Apply Script function, open the Binary Mode dialog and enter the string “Search & Replace©” (no quotes) into the dialog.
3. Click the Apply Script button, navigate to where html tranform example.srs is saved, and select it.
4. Click the “Open” button. html tranform example.srs will operate on the search (or replace) string and “Search & Replace©” and it will be changed to “Search & Replace©”
5 Click the OK button to use the transformed string to conduct your primary search (or replace).