HighlightRegex

TextFrame.HighlightRegex method

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

public void HighlightRegex(string regex, Color highlightColor, ITextHighlightingOptions options)
ParameterTypeDescription
regexStringText of regular expression to get text to highlight.
highlightColorColorHighlighting color.
optionsITextHighlightingOptionsHighlighting options.

Examples

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

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx")){
	TextHighlightingOptions options = new TextHighlightingOptions();
	// highlighting all words with 10 symbols or longer
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.HighlightRegex(@"\b[^\s]{5,}\b", Color.Blue, options);
	presentation.Save("SomePresentation-out.pptx", SaveFormat.Pptx);
}

See Also