跳到主要内容

SetRegularExp

设置字段的正则表达式。

语法

expression.SetRegularExp(regularExpression);

expression - 表示 ApiComboboxField 类的变量。

参数

名称必需/可选数据类型默认值描述
regularExpression必需string验证正则表达式(例如 "\S+@\S+\.\S+")

返回值

boolean

示例

在 PDF 中使用模式规则验证字段输入。

// Can I check that data matches a pattern in a PDF?

// Ensure text follows a specific format in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let comboboxField = Api.CreateComboboxField([10, 10, 160, 30]);
page.AddObject(comboboxField);

comboboxField.SetRegularExp("\\S+@\\S+\\.\\S+");
comboboxField.SetValue("example@gmail.com");