Finds and replaces all occurrences of the given pattern with another pattern. Complexity: varying.
This method is a replacement for IFileDocument.ReplaceAll when used in scripting languages.
Searching all pattern occurrences
var fdoc = new ActiveXObject("FileDocument.FileDocument");
var msel = fdoc.CreateEmptySelection();
fdoc.Open("c:\\temp\\file.txt");
msel.AddRange(0, fdoc.FileSize); // We'll be searching in a whole file
var pattern1 = fdoc.CreateSequence();
var pattern2 = fdoc.CreateSequence();
pattern1.AddData(HexBytes, 0x0d, 0x0a); // EOL pattern
pattern2.AddData(HexBytes, 0x0d, 0x0a, 0x0d, 0x0a); // Double-EOL pattern
var nReplacements = fdoc.ToNumber(fdoc.ReplaceAllS(pattern1, pattern2, false, msel);