Select a base directory and a file name pattern such as *.txt to specify where and what to seach.
Once the FIND command has run, you can operate on the set of found files. To exclude a file from a replace, rename or other operation, just uncheck the checkbox in the left column of the result list.
Thus changing
<h2 id="super">Super Title!</h2>
to
<h2 id="super"><a name="super">Super Title!</a></h2>
and so on.
You might use the following expression:
<h2 id="(\w+)">([^<]+)</h2>
with the following replacement text:
<h2 id="\1"><a name="\1">\2</a></h2>
Here the first bracket captures the id and the second bracket captures the heading it self. We use [^<]+, i.e. "any-character-but-<-at-least-once" to get the entire tag content. \1 and \2 refer to the respective brackets, called capturing groups, in the replacement text.
Read the regular expressions help for further details.
However, there is an option in the FAR settings that, if disabled, allows to modify binary files: "Exclude binary files from replace operation". Use at your own risk.
Text that continues
on a second line.
No obscure construct such as "$\r?(?s:.)^
" is required.
But there are situations when you do not know how many lines to find. Say you want to find all the Foo nodes in an XML document, that is all the text from <Foo> to </Foo>. If such a node can span any number of lines, you will need to apply the following expression:
<Foo>(?s:.+?)</Foo>
This combines the "dotall" flag ?s: with the quite exotic "reluctant" quantifier +?. The dotall flag makes the dot (.) represent line breaks also (wich it normaly does not). The "reluctant" quantifier +? prevents the regular expression parser from expanding the found text to the last closing </Foo> tag in the document.
Next make sure only those files are checked (checkbox in left column of file list), that should have their encoding changed. Uncheck all other files, if any.
Eventually open the Tools menu and select the new encoding from the Change Encoding menu item.
Just type "Betty, Alphonse" into the Find... field, tick the Regular Expression checkbox and type "Alphonse Betty" into the Replace With... field. That's it. It will work just fine, because comma and space are not special characters in regular expressions.
Type "\?" into the Find... field, tick the Regular Expression checkbox and leave the Replace With... field empty. While the question mark is a regular expression special character, the backslash is the regular expression escape character. Thus the escape sequence "\?" will be read as a simple question mark and be replaced with ... nothing.