> 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/34cff7cafbbfcd416778a35b63cb058c27bcda8b) **\[用户资料] → 设置**.
2. 在右侧，在……下方 *例外列表* 部分下，选择 **SKU**.
3. 选择 **添加新的 SKU 列表**.
4. 输入一个 **列表名称**.
5. 选择 **设置的事件类型** 你要与此 SKU 列表关联的项目。

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

1. 选择 **显示高级设置** 并在其中输入你的正则表达式 **匹配表达式** 字段中添加 1 个。
   * 在括号内，只添加你想要匹配的值：
     * 添加我们已知牙科 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 种方式之一列出你要匹配的值：
   * **手动添加项目** 通过在……中输入 TOOTH、SMILE 和 SHINE *SKU* 字段。

     <div data-with-frame="true"><figure><img src="/files/6c535809367bbd14cd21b80f6dafbfd8dd5fa6da" alt="" width="375"><figcaption></figcaption></figure></div>
   * 或者， **上传 CSV 或 Excel 文件** 将 TOOTH、SMILE 和 SHINE 列在……下方 *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 列表 *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, and the optional `goal` 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>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
