ReplaceRegex()

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

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

void Aspose::Slides::Presentation::ReplaceRegex(System::SharedPtr<System::Text::RegularExpressions::Regex> regex, System::String newText, System::SharedPtr<IFindResultCallback> callback) override

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 regex = System::MakeObject<System::Text::RegularExpressions::Regex>(u"\\b[^\\s]{10,}\\b");

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

See Also