正则表达式和通配符修改器

启用文本样式搜索的多种属性都支持正则表达式和通配符修改器。 使用这些修改器的主要目的是为将特殊规则添加到文本比较以便 Integration Service 可以为指定的文本样式执行更加准确的搜索。 正则表达式和通配符修改器与其他特殊字符的区别在于他们仅仅用于修改文本样式搜索,因此他们最终不会被嵌入到已处理的数据中。

可以通过属性右侧出现的 控件来标识支持正则表达式或通配符修改器的属性。 单击 可查看受支持的正则表达式或通配符修改器的列表,单击所需的修改器可将其添加到属性。

在某些属性页中,可能需要启用“使用正则表达式”属性才能启用 控件。 在其他属性页中,必须从“搜索方法”下拉列表中选择“使用通配符(* 和 ?)”或“使用正则表达式”才能使用此控件。

Closed示例: 正则表达式修改器

假设所有“打印命令脚本”触发器文件当前都打印到 Zebra 打印机:

%BTW% /AF="MyFile.btw" /PRN=”Zebra (1)” /P

%END%

您已经使用现有的“打印命令脚本”触发器文件创建了文件集成,但是希望将打印作业重新定位到 Datamax 打印机。 您无需手动编辑所有触发器文件来更新打印机,只需添加一个“搜索并替换”操作即可实现此目的,该操作将会搜索“ZebraXXX”样式并将其替换为“Datamax”。

如果样式为完全匹配,例如“Zebra”到“Datamax”,那么无需使用正则表达式修改器。 However, if the printing criteria is more complex, a regular expression modifier may be necessary. In this example, the existing Print Command Script trigger files are printing to multiple printers, "Zebra (1)," "Zebra (2)," and "New Zebra." 您希望将打印作业仅从“Zebra (1)”和“Zebra (2)”重定向到“Datamax”。

In this case, regular expression modifiers allow you to execute a more precise search.

ClosedTo add regular expression modifiers to a Search and Replace action

  1. In the Options section of the Search and Replace property page, select Use Regular Expression from the Search Method dropdown list.

  2. In the Search for box, type “Zebra”.

  3. 立即在字母“a”后面找到光标。

  4. 单击 并从正则表达式修改器列表中选择“?”。

  5. 再次单击 并从正则表达式修改器列表中选择“*”。

搜索”框中的结果为““Zebra.*””。 通过此设置可以指定“Zebra”后跟随任意字符,直到到达双引号字符。

  • “.” 字符将会匹配任意单个字符。

  • “*” 字符将会匹配 0 或多次。

By combining "." and "*" into “Zebra.*”, your search will match double-quote plus Zebra plus any number of trailing characters until the end double-quote is reached. 在触发器文件中找到这些实例时,他们将被替换为“Datamax”。

Closed示例: Wildcard Modifiers

通配符修改器可用于替换字符串中的一个或多个字符。 The following procedure assumes the same scenario as described in the previous example, but the Search and Replace action uses wildcard modifiers.

ClosedTo add wildcard modifiers to a Search and Replace action

  1. In the Options section of the Search and Replace property page, select Use Wildcards (* and ?) from the Search Method dropdown list.

  2. In the Search for box, type “Zebra”.

  3. 立即在字母“a”后面找到光标。

  4. 单击 并从通配符修改器列表中选择“?”。

  5. 再次单击 并从通配符修改器列表中选择“*”。

“搜索”框中的结果为““Zebra?*””。 通过此设置可以指定“Zebra”后跟随任意字符。

使用通配符搜索的方法并不如使用正则表达式搜索的方法强大。 使用通配符搜索可能并不会产生等效的匹配。