--- title: "How to add a Regular Expression to a Trigger" slug: "how-to-add-a-regular-expression-to-a-trigger" updated: 2025-01-23T09:23:16Z published: 2025-01-23T09:23:16Z canonical: "support.tulip.co/how-to-add-a-regular-expression-to-a-trigger" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 如何在触发器中添加正则表达式 ## 正则表达式概述 **正则表达式**是一种有用的工具,可用于创建模式,帮助匹配和定位数据库中存储的文本/字符串。 正则表达式通常缩写为 "**regex**",与 Microsoft Excel 中使用的表达式以及 Perl 等编程语言中使用的表达式类似。 ## 如何使用 要使用正则表达式工具,首先要创建一个变量。 创建后,您就可以**在触发器中**轻松添加正则表达式作为**条件**。 以下指南将帮助您在 Tulip 中创建正则表达式: **如何识别某些条形码** 1- 在 Tulip 应用程序编辑器中的所需应用程序中打开一个步骤。 2- 点击上下文窗格中步骤选项卡下的加号图标,选择触发器。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_92389779.png) 1. 填写触发器编辑器顶部的标题,为触发器命名。 2. 设置事件: 3. 在下拉菜单中选择 "设备 4. 在第二个下拉菜单中选择 "条形码扫描仪 5. 在第三个下拉菜单中选择 "此站点 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_92390281.png){height="" width="""} 5-设置条件: - 单击窗口右侧 "**如果 "**部分中的 "添加新条件 "按钮。 - 在下拉菜单中选择 "变量"。 - 选择您在下拉菜单中创建的变量,例如**装配条形码**。 - 在下拉菜单中选择 "匹配正则表达式"。 - 在下拉菜单中选择 "静态值"。 - 在下拉菜单中选择 "文本"。 - 在最后一个框中键入正则表达式。Eg.[U]+[a-zA-Z0-9].{9} - 该表达式查找以大写字母 "U "开头并包含九个附加字符的条形码。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_92390558.png) 1. 设置操作: 2. 单击窗口右侧 "然后 "部分的 "添加新操作 "按钮。 3. 在下拉菜单中选择 "转到步骤"。 4. 在下拉菜单中选择所需的操作。例如:下一步。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_92390705.png) 下面是完整触发器的外观: ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_92391067.png){height="" width="""} 要进一步了解如何使用 regex,[这里有一个我们认为很有帮助的工具](https://regexr.com/)。 ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20to%20add%20a%20Regular%20Expression%20to%20a%20Trigger_74334442.png){height="" width="""} 为了有效使用该链接,请在文本框 (2) 中键入一个句子/段落,并使用表达式部分 (1) 定义搜索条件。 工具部分 (3) 将解释表达式中每个命令的功能。Cheatsheet 和 Community 标签 (4) 是其他有用的工具,可以帮助你建立更好的表达式。 --- 找到您想要的了吗? 你还可以前往[community.tulip.co](https://community.tulip.co/?utm_source=intercom&utm_medium=article-link&utm_campaign=all)发布你的问题,或者看看其他人是否也遇到过类似的问题!