Aspose::Words::Replacing::FindReplaceOptions::get_LegacyMode method

FindReplaceOptions::get_LegacyMode method

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

bool Aspose::Words::Replacing::FindReplaceOptions::get_LegacyMode() const

Examples

Shows how to recognize and use substitutions within replacement patterns.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

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

auto regex = MakeObject<System::Text::RegularExpressions::Regex>(u"([A-z]+) gave money to ([A-z]+)");

auto options = MakeObject<FindReplaceOptions>();
options->set_UseSubstitutions(true);

// Using legacy mode does not support many advanced features, so we need to set it to 'false'.
options->set_LegacyMode(false);

doc->get_Range()->Replace(regex, u"$2 took money from $1", options);

ASSERT_EQ(doc->GetText(), u"Paul took money from Jason.\f");

See Also