Special Replacement Mode – Capitalization

Capitalization matching is enabled in Options|Replace and scripts. using the Replace Processing switch. This is a special mode in which the program either capitalizes or uses the letter case of existing text while making a replacement. A ‘word’ consists of an alphabetic string surrounded by whitespace. The replacement string does not have to be the same length as the search string. For example, if your search gets a hit on the ‘word’ Cat, you can change that Mouse also change letter case at the same time. Regular expression mode can be enabled or not.

Special Note: Replace Processing is a special operation that should be enabled only if you need it. It is intended for simpler search/replaces. In particular, the ‘Match Case’ choice functions best when the search term has clear literal boundaries. Please test complex regular expression mode search/replaces with the ‘Match Case’ choice enabled in advance. The program tries to determine the existing letter case by ‘words’ surrounded by whitespace. If the existing text is mixed letter case within ‘words’ or the search term yields ‘words’ that contain non-letter characters or line boundaries, the program may have trouble determining the existing letter case. You can preview replaces by enabling Display Replace String in Options|Output and running a search. If results are not what you expect, try using a more narrow search term.

Three Replace Processing choices are available:

None: Standard mode. No special letter case changes made.

Capitalize All Words: The program capitalizes ‘words’ while making the replacement. For example, if the search string is coffee or tea and the replace string is bitter or sweet, the replace would be Bitter Or Sweet. This mode can be used with regular expressions. For example,

S:<title>*</title>

R:<title>%1\</title>

will change <title>funduc software inc</title> into <Title>Funduc Software Inc</Title>.

Match Capitalization: If the letter case of the existing text found is consistent within “words” the program will match the overall capitalization of the search hit and apply that while making the replace. For most searches this means if the first two alphabetic characters of the first ‘word’ is lower case, the replace will be lower case and visa versa. If the 1st is capital and the 2nd is lower, the replace case is 1st letter cap, remainder lower. If the search and replace strings differ in length, the pattern detected in the search will be continued forward replace string. This mode can be used with regular expressions. Some example are below.

File Contents S/R Strings Result

Cats or Mice S:cats or mice

R: mice n rats or cats Mice N Rats Or Cats

 

cats or mice “

mice n rats or cats

 

CATS OR MICE “

MICE N RATS OR CATS

 

caTs or mICE “

mice n rats or cats

 

CATS or mice “

MICE n rats or cats

 

CATS or mice S:ca* or mi+[a-zA-Z]

R: mice n rats or cats MICE n rats or cats

 

Cats Or Mice

Mice N Rats Or Cats

Capitalization Processing