We introduced scenarios in the HandyFile Find And Replace so that you can get rid of the monotonous operations that involve searching and replacing many different portions of text in multiple files. Let us consider an example of cleaning HTML files saved from within Microsoft Word.
We will want to:
SPAN tags containing LANG attributes and mso style definitions; <o:p> tags; [if] conditions.There are much more Word dirt in the HTML but we shall limit our example to these searches.
We start by opening the Scenario editor by clicking the Advanced Search button and selecting Manage Scenarios from the menu.
In the Scenario dialog, create a new scenario by clicking the New button. Type the name of the new scenario, for example, Clean up Word HTML.
After the new scenario is created, start adding actions to it.
\<\!\-\-.#\-\-\>
Here:
\<\!\-\- is the comment opening tag;.#
(any character + match 1or more times non-greedy) means "match all further text but stop before the next symbol in the
expression (non-greedy)";\-\-\> is the comment
closing tag.Please note that you should escape all non-alphanumeric symbols when searching with regular expressions.
As we want to remove comments, we leave the Replace with field blank.
\<span\s#lang\=\w#\-\w#\s#style\=\'mso.#\'\>(.#)\<\/span\>
Here:
#lang\=\w#\-\w# stands for the LANG attribute with the
language abbreviation;style\=\'mso.#\' matches any style attribute starting from any mso style attribute;(.#) is the tag inner text that we must preserve.We replace the found text with the tag inner text:
\1
We shall omit operations on adding actions for being short.
Find what: <o:p></o:p>
Replace with: empty
Find what: \<HTML.#\>
Replace with: <HTML>
Please note that escapes are optional in the replace field.
And lastly, we shall remove the Office [if] conditions.
Find what: \<\!\[if\s.#\]\>(.#)\<\!\[endif\]\>
Replace with: \1
Please note that escapes are optional in the replace field.
We have now created a new scenario. Click the Save and Activate button. The Files and Text Tab will change to the Advanced mode displaying the scenario name.
Now do the common operations:
C:\MyWebFiles\Projects
*.htm*Note
Please do not forget that you can run the HFFR from the command line and specify
the name of a scenario to activate by using the parameter /scn:"scenario_name".
| © 2002-2006 | This help file was built with |