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.2
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 exampleMatchCase
True indicates case-sensitive comparison, false indicates case-insensitive comparison.
Public propertyCode examplePreserveMetaCharacters
True indicates that meta-characters beginning with "&" are preserved. Default value is false.
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.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Simple find and replace operation.
// Open the document
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;

// Replace the text in the document
doc.Range.Replace("_CustomerName_", "James Bond", options);

// Save the modified document
doc.Save(ArtifactsDir + "Range.ReplaceSimple.docx");
See Also