HighlightRegex

ITextFrame.HighlightRegex method

Highlights all matches of the regular expression with the specified color.

public void HighlightRegex(Regex regex, Color highlightColor, IFindResultCallback callback)
ParameterTypeDescription
regexRegexThe regular expression Regex to get strings to highlight.
highlightColorColorThe color to highlight the text.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

Examples

The following code sample shows how to highlight text in a TextFrame using a regular expression.

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

See Also