跳到主要内容

Search

在段落对象的范围内搜索。搜索结果是 ApiRange 对象的集合。

语法

expression.Search(sText, isMatchCase);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
sText必需string搜索字符串。
isMatchCase必需boolean是否区分大小写。

返回值

ApiRange[]

示例

此示例展示如何在段落中进行搜索。

// How to find a word in the paragraph.

// Make the search result word bold.

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);