findWholeWordsOnly property

FindReplaceOptions.findWholeWordsOnly property

True indicates the oldValue must be a standalone word.

get findWholeWordsOnly(): boolean

Examples

Shows how to toggle standalone word-only find-and-replace operations.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

builder.writeln("Jackson will meet you in Jacksonville.");

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
let options = new aw.Replacing.FindReplaceOptions();

// Set the "FindWholeWordsOnly" flag to "true" to replace the found text if it is not a part of another word.
// Set the "FindWholeWordsOnly" flag to "false" to replace all text regardless of its surroundings.
options.findWholeWordsOnly = findWholeWordsOnly;

doc.range.replace("Jackson", "Louis", options);

expect(doc.getText().trim()).toEqual(
  findWholeWordsOnly ? "Louis will meet you in Jacksonville." : "Louis will meet you in Louisville." );

See Also