> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-inside-the-parentheses.md).

# 括号内的正则

[正则表达式](/brand/zh/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.md) （或正则表达式）是一种代码类型，当你希望将上传的商品 SKU、类别或促销代码中的部分字符与随转化一起传递给 impact.com 的值进行匹配时，可以使用它。你可以将正则表达式与 impact.com 的 Match Expression 工具结合使用，以识别你希望采用不同支付方式的商品 SKU、类别或促销代码。

#### 在括号内

将正则表达式的一部分放在括号内，可以把该部分正则表达式组合在一起。然后，Match Expression 工具可以提取你放在括号之间的值，并在你提供的相应例外列表项中查找匹配项。你添加到例外列表中的项目应与括号内的正则表达式完全匹配，这样该正则表达式 [括号外](/brand/zh/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-outside-the-parentheses.md) 就可以应用于整个列表。

#### 示例场景

你的品牌， *ACME Smile*，希望当顾客购买任何牙科产品时，向合作伙伴支付 5%。 *ACME Smile* 并没有一份覆盖所有牙科产品的完整 SKU 清单，因为你的品牌一直在移除产品并添加新产品。不过，你确实知道所有牙科产品的 SKU 都以 TOOTH、SMILE 或 SHINE 开头（例如 `SHINE98763`, `SMILE987abc`, `TOOTH65abc64`).

由于所有牙科 SKU 都以 TOOTH、SMILE 或 SHINE 开头，你可以为牙科产品 SKU 整体设置一个正则表达式，并使用 Match Expression 工具在不完整的 SKU 例外列表中查找匹配项，如下文所示。

#### 步骤 1：创建 SKU 列表

1. 从顶部导航栏中，选择 ![](/files/1cbb667ec4878308f24ec4acd13cbf03ede0bdfe) **\[User profile] → Settings**.
2. 在右侧，位于 *例外列表* 部分下，选择 **SKU**.
3. 选择 **添加新的 SKU 列表**.
4. 输入一个 **列表名称**.
5. 选择 **事件类型** ，以将其与此 SKU 列表关联。

#### 步骤 2：设置正则表达式

1. 选择 **显示高级设置** 并在 **Match Expression** 字段中输入你的正则表达式。
   * 在括号内，只添加你要匹配的值：
     * 添加我们已知牙科 SKU 开头的 3 个字符字符串，并用正则表达式字符分隔 `|` ，表示“或”。
   * 在括号外，添加任何有助于细化匹配的正则表达式：
     * 添加正则表达式字符 `^` 在左括号前，用于断言行首位置，确保前面没有任何字符。
     * 添加正则表达式字符 `.` 在右括号后，用于匹配后续任何字符（例如数字、字母、连字符），但不包括行结束符。
     * 添加正则表达式字符 `*` 在句点后，用于查找任意数量的匹配项（即从 0 到无限个匹配）。
   * 最终表达式应为 `^(TOOTH|SMILE|SHINE).*`.
2. 选择 **保存并添加项目**.

   <div data-with-frame="true"><figure><img src="/files/21ec649974d23f6f2023d967f91e9f316c297798" alt="" width="563"><figcaption></figcaption></figure></div>

#### 步骤 3：添加例外列表项

1. 以下 2 种方式中的任意一种来列出你想匹配的值：
   * **手动添加项目** 通过在 *Sku* 字段。

     <div data-with-frame="true"><figure><img src="/files/6c535809367bbd14cd21b80f6dafbfd8dd5fa6da" alt="" width="375"><figcaption></figcaption></figure></div>
   * 中输入 TOOTH、SMILE 和 SHINE **或者，** 上传 CSV 或 Excel 文件 *SKU* 并在

     * 请参见 [创建 SKU 例外列表](/brand/zh/what-would-you-like-to-learn-about/account-administration/program-settings/exception-lists/create-category-and-sku-exception-lists.md#create-a-sku-exception-list-0-4) 了解更多信息。

     <div data-with-frame="true"><figure><img src="/files/77ead5f7a848ddf21ad98672a9073f3a415eff0f" alt="" width="374"><figcaption></figcaption></figure></div>
2. 选择 **保存**.
   * 你会在 *SKU 列表* 页面上获取你整体项目的通用跟踪链接。

#### 接下来做什么？

现在你已经设置了一个正则表达式 Match Expression，并添加了这 3 个 SKU 列表项，所有 *ACME Smile*未来的牙科产品（假设它们的 SKU 也以 TOOTH、SMILE 或 SHINE 开头）都将被匹配并视为例外列表的一部分。任何与该正则表达式匹配的传入转化都将被标记为例外列表的一部分，并相应地应用合同规则。

现在你可以向 *ACME Smile*的模板条款添加规则，例如当这些 SKU 出现时按每笔订单支付 5%。请参阅 [为 SKU 例外列表设置支付金额](/brand/zh/what-would-you-like-to-learn-about/account-administration/program-settings/exception-lists/create-category-and-sku-exception-lists.md#set-payouts-for-a-sku-exception-list-0-5) 了解更多详情。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-inside-the-parentheses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
