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()Initializes a new instance of the FindReplaceOptions class with default settings.
FindReplaceOptions(Aspose::Words::Replacing::FindReplaceDirection)Initializes a new instance of the FindReplaceOptions class with the specified direction.
FindReplaceOptions(Aspose::Words::Replacing::FindReplaceDirection, const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback> &)Initializes a new instance of the FindReplaceOptions class with the specified direction and replacing callback.
FindReplaceOptions(const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback> &)Initializes a new instance of the FindReplaceOptions class with the specified replacing callback.
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_IgnoreOfficeMath() constGets or sets a boolean value indicating either to ignore text inside OfficeMath/>. The default value is true.
get_IgnoreShapes() constGets or sets a boolean value indicating either to ignore shapes within a text.

The default value is false. | | get_IgnoreStructuredDocumentTags() const | Gets or sets a boolean value indicating either to ignore content of StructuredDocumentTag. The default value is false. | | get_LegacyMode() const | Gets or sets a boolean value indicating that old find/replace algorithm is used. | | get_MatchCase() const | True indicates case-sensitive comparison, false indicates case-insensitive comparison. | | get_ReplacementFormat() const | Specifies format of the replacement. Default is Text. | | get_ReplacingCallback() const | The user-defined method which is called before every replace occurrence. | | get_SmartParagraphBreakReplacement() const | Gets 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() const | True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false. | | get_UseSubstitutions() const | Gets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false. | | set_Direction(Aspose::Words::Replacing::FindReplaceDirection) | Selects direction for replace. Default value is Forward. | | set_FindWholeWordsOnly(bool) | True indicates the oldValue must be a standalone word. | | set_IgnoreDeleted(bool) | Sets a boolean value indicating either to ignore text inside delete revisions. The default value is false. | | set_IgnoreFieldCodes(bool) | Sets a boolean value indicating either to ignore text inside field codes. The default value is false. | | set_IgnoreFields(bool) | Sets a boolean value indicating either to ignore text inside fields. The default value is false. | | set_IgnoreFootnotes(bool) | Sets a boolean value indicating either to ignore footnotes. The default value is false. | | set_IgnoreInserted(bool) | Sets a boolean value indicating either to ignore text inside insert revisions. The default value is false. | | set_IgnoreOfficeMath(bool) | Sets a boolean value indicating either to ignore text inside OfficeMath/>. The default value is true. | | set_IgnoreShapes(bool) | Sets a boolean value indicating either to ignore shapes within a text.

The default value is false. | | set_IgnoreStructuredDocumentTags(bool) | Sets a boolean value indicating either to ignore content of StructuredDocumentTag. The default value is false. | | set_LegacyMode(bool) | Sets a boolean value indicating that old find/replace algorithm is used. | | set_MatchCase(bool) | True indicates case-sensitive comparison, false indicates case-insensitive comparison. | | set_ReplacementFormat(Aspose::Words::Replacing::ReplacementFormat) | Specifies format of the replacement. Default is Text. | | set_ReplacingCallback(const System::SharedPtr<Aspose::Words::Replacing::IReplacingCallback> &) | The user-defined method which is called before every replace occurrence. | | set_SmartParagraphBreakReplacement(bool) | 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. | | set_UseLegacyOrder(bool) | True indicates that a text search is performed sequentially from top to bottom considering the text boxes. Default value is false. | | set_UseSubstitutions(bool) | Sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false. |

Examples

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

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::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 = System::MakeObject<Aspose::Words::Replacing::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(doc->GetText().Trim(), matchCase ? System::String(u"Jade bought a ruby necklace.") : System::String(u"Jade bought a Jade necklace."));

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

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::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 = System::MakeObject<Aspose::Words::Replacing::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(doc->GetText().Trim(), findWholeWordsOnly ? System::String(u"Louis will meet you in Jacksonville.") : System::String(u"Louis will meet you in Louisville."));

See Also