Aspose::Words::Replacing::FindReplaceOptions class

FindReplaceOptions class

Specifies options for find/replace operations. To learn more, visit the Find and Replace documentation article.

class FindReplaceOptions : public System::Object

Methods

MethodDescription
FindReplaceOptions()
FindReplaceOptions(Aspose::Words::Replacing::FindReplaceDirection)
FindReplaceOptions(const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback>&)
FindReplaceOptions(Aspose::Words::Replacing::FindReplaceDirection, const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback>&)
get_ApplyFont() constText formatting applied to new content.
get_ApplyParagraphFormat() constParagraph formatting applied to new content.
get_Direction() constSelects direction for replace. Default value is Forward.
get_FindWholeWordsOnly() constTrue indicates the oldValue must be a standalone word.
get_IgnoreDeleted() constGets or sets a boolean value indicating either to ignore text inside delete revisions. The default value is false.
get_IgnoreFieldCodes() constGets or sets a boolean value indicating either to ignore text inside field codes. The default value is false.
get_IgnoreFields() constGets or sets a boolean value indicating either to ignore text inside fields. The default value is false.
get_IgnoreFootnotes() constGets or sets a boolean value indicating either to ignore footnotes. The default value is false.
get_IgnoreInserted() constGets or sets a boolean value indicating either to ignore text inside insert revisions. The default value is false.
get_IgnoreShapes() constGets a boolean value indicating either to ignore shapes within a text. The default value is false.
get_IgnoreStructuredDocumentTags() constGets or sets a boolean value indicating either to ignore content of StructuredDocumentTag. The default value is false.
get_LegacyMode() constGets or sets a boolean value indicating that old find/replace algorithm is used.
get_MatchCase() constTrue indicates case-sensitive comparison, false indicates case-insensitive comparison.
get_ReplacingCallback() constThe user-defined method which is called before every replace occurrence.
get_SmartParagraphBreakReplacement() constGets or sets a boolean value indicating either it is allowed to replace paragraph break when there is no next sibling paragraph. The default value is false.
get_UseLegacyOrder() constTrue indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false.
get_UseSubstitutions() constGets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.
GetType() const override
Is(const System::TypeInfo&) const override
set_Direction(Aspose::Words::Replacing::FindReplaceDirection)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_Direction.
set_FindWholeWordsOnly(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_FindWholeWordsOnly.
set_IgnoreDeleted(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreDeleted.
set_IgnoreFieldCodes(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFieldCodes.
set_IgnoreFields(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFields.
set_IgnoreFootnotes(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreFootnotes.
set_IgnoreInserted(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreInserted.
set_IgnoreShapes(bool)Sets a boolean value indicating either to ignore shapes within a text. The default value is false.
set_IgnoreStructuredDocumentTags(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_IgnoreStructuredDocumentTags.
set_LegacyMode(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_LegacyMode.
set_MatchCase(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_MatchCase.
set_ReplacingCallback(const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback>&)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_ReplacingCallback.
set_SmartParagraphBreakReplacement(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_SmartParagraphBreakReplacement.
set_UseLegacyOrder(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_UseLegacyOrder.
set_UseSubstitutions(bool)Setter for Aspose::Words::Replacing::FindReplaceOptions::get_UseSubstitutions.
static Type()

Examples

Shows how to toggle case sensitivity when performing a find-and-replace operation.

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

builder->Writeln(u"Ruby bought a ruby necklace.");

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
auto options = MakeObject<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->set_MatchCase(matchCase);

doc->get_Range()->Replace(u"Ruby", u"Jade", options);

ASSERT_EQ(matchCase ? String(u"Jade bought a ruby necklace.") : String(u"Jade bought a Jade necklace."), doc->GetText().Trim());

Shows how to toggle standalone word-only find-and-replace operations.

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

builder->Writeln(u"Jackson will meet you in Jacksonville.");

// We can use a "FindReplaceOptions" object to modify the find-and-replace process.
auto options = MakeObject<FindReplaceOptions>();

// Set the "FindWholeWordsOnly" flag to "true" to replace the found text if it is not a part of another word.
// Set the "FindWholeWordsOnly" flag to "false" to replace all text regardless of its surroundings.
options->set_FindWholeWordsOnly(findWholeWordsOnly);

doc->get_Range()->Replace(u"Jackson", u"Louis", options);

ASSERT_EQ(findWholeWordsOnly ? String(u"Louis will meet you in Jacksonville.") : String(u"Louis will meet you in Louisville."), doc->GetText().Trim());

See Also