HighlightRegex()

TextFrame::HighlightRegex(System::String, System::Drawing::Color, System::SharedPtr<ITextHighlightingOptions>) method

Highlight all matches of regular expression in text frame text using specified color.

void Aspose::Slides::TextFrame::HighlightRegex(System::String regex, System::Drawing::Color highlightColor, System::SharedPtr<ITextHighlightingOptions> options) override

Arguments

ParameterTypeDescription
regexSystem::StringText of regular expression to get text to highlight.
highlightColorSystem::Drawing::ColorHighlighting color.
optionsSystem::SharedPtr<ITextHighlightingOptions>Highlighting options.

Remarks

The following sample code shows how to Highlight Text using regular expression in a PowerPoint Presentation.

auto presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");
auto shape = System::ExplicitCast<Aspose::Slides::AutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));

System::SharedPtr<TextHighlightingOptions> options = System::MakeObject<TextHighlightingOptions>();
// highlighting all words with 10 symbols or longer
shape->get_TextFrame()->HighlightRegex(u"\\b[^\\s]{5,}\\b", System::Drawing::Color::get_Blue(), options);
presentation->Save(u"SomePresentation-out.pptx", SaveFormat::Pptx);

See Also