ReplaceRegex()

ITextFrame::ReplaceRegex(System::SharedPtr<System::Text::RegularExpressions::Regex>, System::String, System::SharedPtr<IFindResultCallback>) method

Replaces all matches of the regular expression with the specified string.

virtual void Aspose::Slides::ITextFrame::ReplaceRegex(System::SharedPtr<System::Text::RegularExpressions::Regex> regex, System::String newText, System::SharedPtr<IFindResultCallback> callback)=0

Arguments

ParameterTypeDescription
regexSystem::SharedPtr<System::Text::RegularExpressions::Regex>The regular expression System::Text::RegularExpressions::Regex to get strings to replace.
newTextSystem::StringThe string to replace all occurrences of the strings to be replaced.
callbackSystem::SharedPtr<IFindResultCallback>The callback object for receiving search results IFindResultCallback.

Remarks

The following code sample shows how to replace text using regular expression with the specified string.

auto presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");
auto shape = System::ExplicitCast<AutoShape>(presentation->get_Slide(0)->get_Shape(0));

auto regex = System::MakeObject<System::Text::RegularExpressions::Regex>(u"\\b[^\\s]{10,}\\b");

// Replace all words with 10 or more characters with '<em><strong>'
shape->get_TextFrame()->ReplaceRegex(regex, u"</strong></em>", nullptr);
presentation->Save(u"SomePresentation-out.pptx", SaveFormat::Pptx);

See Also