FindReplaceOptions

FindReplaceOptions class

Specifies options for find/replace operations.

To learn more, visit the Find and Replace documentation article.

public class FindReplaceOptions

Constructors

Name Description
FindReplaceOptions() The default constructor.
FindReplaceOptions(FindReplaceDirection)
FindReplaceOptions(IReplacingCallback)
FindReplaceOptions(FindReplaceDirection, IReplacingCallback)

Properties

Name Description
ApplyFont { get; } Text formatting applied to new content.
ApplyParagraphFormat { get; } Paragraph formatting applied to new content.
Direction { get; set; } Selects direction for replace. Default value is Forward.
FindWholeWordsOnly { get; set; } True indicates the oldValue must be a standalone word.
IgnoreDeleted { get; set; } Gets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is false.
IgnoreFieldCodes { get; set; } Gets or sets a boolean value indicating either to ignore text inside field codes. The default value is false.
IgnoreFields { get; set; } Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false.
IgnoreFootnotes { get; set; } Gets or sets a boolean value indicating either to ignore footnotes. The default value is false.
IgnoreInserted { get; set; } Gets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is false.
IgnoreStructuredDocumentTags { get; set; } Gets or sets a boolean value indicating either to ignore content of StructuredDocumentTag. The default value is false.
LegacyMode { get; set; } Gets or sets a boolean value indicating that old find/replace algorithm is used.
MatchCase { get; set; } True indicates case-sensitive comparison, false indicates case-insensitive comparison.
ReplacingCallback { get; set; } The user-defined method which is called before every replace occurrence.
SmartParagraphBreakReplacement { get; set; } Gets or sets a boolean value indicating either it is allowed to replace paragraph break when there is no next sibling paragraph.
UseLegacyOrder { get; set; } True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false.
UseSubstitutions { get; set; } Gets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

Examples

Shows how to toggle case sensitivity when performing a find-and-replace operation.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Ruby bought a ruby necklace.");

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

// Set the "MatchCase" flag to "true" to apply case sensitivity while finding strings to replace.
// Set the "MatchCase" flag to "false" to ignore character case while searching for text to replace.
options.MatchCase = matchCase;

doc.Range.Replace("Ruby", "Jade", options);

Assert.AreEqual(matchCase ? "Jade bought a ruby necklace." : "Jade bought a Jade necklace.",
    doc.GetText().Trim());

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

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

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

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
FindReplaceOptions options = new 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);

Assert.AreEqual(
    findWholeWordsOnly ? "Louis will meet you in Jacksonville." : "Louis will meet you in Louisville.",
    doc.GetText().Trim());

See Also