FindReplaceOptions Class

Specifies options for find/replace operations.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.ReplacingFindReplaceOptions

Namespace:  Aspose.Words.Replacing
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.5.0

ExpandedSyntax

public class FindReplaceOptions

The FindReplaceOptions type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodFindReplaceOptions
Initializes a new instance of the FindReplaceOptions class
Public methodFindReplaceOptions(FindReplaceDirection)
Initializes a new instance of the FindReplaceOptions class
Public methodFindReplaceOptions(IReplacingCallback)
Initializes a new instance of the FindReplaceOptions class
Public methodFindReplaceOptions(FindReplaceDirection, IReplacingCallback)
Initializes a new instance of the FindReplaceOptions class

ExpandedProperties

  NameDescription
Public propertyCode exampleApplyFont
Text formatting applied to new content.
Public propertyCode exampleApplyParagraphFormat
Paragraph formatting applied to new content.
Public propertyCode exampleDirection
Selects direction for replace. Default value is Forward.
Public propertyCode exampleFindWholeWordsOnly
True indicates the oldValue must be a standalone word.
Public propertyCode exampleIgnoreDeleted
Gets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is false.
Public propertyCode exampleIgnoreFields
Gets or sets a boolean value indicating either to ignore text inside fields. The default value is false.
Public propertyCode exampleIgnoreInserted
Gets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is false.
Public propertyCode exampleLegacyMode
Gets or sets a boolean value indicating that old find/replace algorithm is used.
Public propertyCode exampleMatchCase
True indicates case-sensitive comparison, false indicates case-insensitive comparison.
Public propertyCode exampleReplacingCallback
The user-defined method which is called before every replace occurrence.
Public propertyCode exampleSmartParagraphBreakReplacement

Gets or sets a boolean value indicating either it is allowed to replace paragraph break when there is no next sibling paragraph.

The default value is false.

Public propertyCode exampleUseLegacyOrder
True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false.
Public propertyCode exampleUseSubstitutions
Gets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

ExpandedMethods

  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

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());

ExpandedSee Also