Skip to main content

Search

Searches for a scope of a paragraph object. The search results are a collection of ApiRange objects.

Syntax

expression.Search(sText, isMatchCase);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTextRequiredstringSearch string.
isMatchCaseRequiredbooleanCase sensitive or not.

Returns

ApiRange[]

Example

Search for a word inside a paragraph and bold the first match in a document.

// How do I find a specific word within a paragraph in a document?

// Highlight a search result by applying bold formatting to the found text in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is just a sample text. This text was added to the paragraph.");
let searchResults = paragraph.Search("text");
searchResults[0].SetBold(true);