跳到主要内容

Search

搜索内容控件对象的范围。搜索结果是 ApiRange 对象的集合。

语法

expression.Search(text, isMatchCase);

expression - 表示 ApiBlockLvlSdt 类的变量。

参数

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

返回值

ApiRange[]

示例

在文档中的内容控件对象中进行搜索。

// Create a block content control, add two paragraphs to it, and search for the specified word among the text in this container in a document.

// Search for the specified word in the block level content control and return it as the range object.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
let paragraph1 = Api.CreateParagraph();
paragraph1.AddText("This is the first paragraph in the content control.");
blockLvlSdt.AddElement(paragraph1, 0);
let paragraph2 = Api.CreateParagraph();
paragraph2.AddText("This is the second paragraph in the content control.");
blockLvlSdt.AddElement(paragraph2, 1);
doc.AddElement(0, blockLvlSdt);
blockLvlSdt.Search("paragraph")[1].SetBold(true);