FindReplaceOptions Class

Specifies options for find/replace operations.

Inheritance Hierarchy

SystemObject
  Aspose.Words.ReplacingFindReplaceOptions

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

Syntax

public class FindReplaceOptions

The FindReplaceOptions type exposes the following members.

Constructors

  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

Properties

  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 propertyLegacyMode
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 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.

Methods

  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)

Examples

Simple find and replace operation.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Hello _CustomerName_,");

// Check the document contains what we are about to test
Console.WriteLine(doc.FirstSection.Body.Paragraphs[0].GetText());

FindReplaceOptions options = new FindReplaceOptions();
options.MatchCase = false;
options.FindWholeWordsOnly = false;

doc.Range.Replace("_CustomerName_", "James Bond", options);

doc.Save(ArtifactsDir + "Range.ReplaceSimple.docx");

See Also