FindReplaceOptionsLegacyMode Property

Gets or sets a boolean value indicating that old find/replace algorithm is used.

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


public bool LegacyMode { get; set; }

Property Value

Type: Boolean


Use this flag if you need exactly the same behavior as before advanced find/replace feature was introduced. Note that old algorithm does not support advanced features such as replace with breaks, apply formatting and so on.


Shows how to recognize and use substitutions within replacement patterns.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("Jason gave money to Paul.");

Regex regex = new Regex(@"([A-z]+) gave money to ([A-z]+)");

FindReplaceOptions options = new FindReplaceOptions();
options.UseSubstitutions = true;

// Using legacy mode does not support many advanced features, so we need to set it to 'false'.
options.LegacyMode = false;

doc.Range.Replace(regex, @"$2 took money from $1", options);

Assert.AreEqual(doc.GetText(), "Paul took money from Jason.\f");

ExpandedSee Also