FindReplaceOptionsMatchCase Property

True indicates case-sensitive comparison, false indicates case-insensitive comparison.

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


public bool MatchCase { get; set; }

Property Value

Type: Boolean


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.",

ExpandedSee Also