> 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).

# 括号内的正则表达式

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

#### 括号内

将正则表达式的一部分放在括号内，即可将该部分组合起来。随后，“匹配表达式”工具可以提取您放在括号之间的值，并在您提供的对应例外列表项中查找匹配项。您添加到例外列表中的项应与括号内的正则表达式完全一致，以便将括号 [之外的正则表达式](https://help.impact.com/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 设置通用正则表达式，并使用“匹配表达式”工具在不完整的 SKU 例外列表中查找匹配项，如以下章节所示。

{% stepper %}
{% step %}

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

1. 在顶部导航栏中，选择 ![](https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2F210dEQa93qyQgoJDkieL%2FUser%20profile.svg?alt=media\&token=f84c5b17-fae4-4a30-990a-9de5e57a150b) **\[用户个人资料] → 设置**.
2. 在右侧的 *例外列表* 部分中，选择 [**SKU**](https://app.impact.com/secure/advertiser/campaign/itemlist/view-skuitemlist-flow.ihtml).
3. 选择 **添加新 SKU 列表**.
4. 输入 **列表名称**.
5. 选择 **事件类型** 以关联此 SKU 列表。
   {% endstep %}

{% step %}

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

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

<div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FWFAYx47NL9zXEA7EqkOt%2Fimage.png?alt=media&amp;token=ff38cad6-a0c1-4c00-b39d-36025dd0d053" alt="" width="563"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

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

1. 通过以下两种方式之一列出您要匹配的值：
   * **手动添加项目** 方法是在 *SKU* 字段。<br>

     <div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FoH6QfzDRJSsLdiFFuhiG%2FUntitled%20design%20(29).png?alt=media&amp;token=ecf9885b-292b-4651-9b56-df904665a10e" alt="" width="375"><figcaption></figcaption></figure></div>
   * 或者， **上传 CSV 或 Excel 文件** 在 *SKU* 列下列出 TOOTH、SMILE 和 SHINE。

     * 请参阅 [创建 SKU 例外列表](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/account-administration/program-settings/exception-lists/create-sku-exception-lists.md) 了解更多信息。

     <div data-with-frame="true"><figure><img src="https://1186853034-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2FqngJxT1772eJGcigeZMu%2FUntitled%20design%20(30).png?alt=media&amp;token=c030c1ca-d821-43a8-b304-558c6e47ab7d" alt="" width="374"><figcaption></figcaption></figure></div>
2. 选择 **保存**.
   * 您会在 *SKU 列表* 页面上看到新建的 SKU 列表。
     {% endstep %}
     {% endstepper %}

#### 接下来呢？

现在，您已设置正则表达式匹配项并添加了 3 个 SKU 列表项， *ACME Smile*今后的所有牙科产品（假设其 SKU 也以 TOOTH、SMILE 或 SHINE 开头）都将作为例外列表的一部分进行匹配。任何符合正则表达式的传入转化都会被标记为例外列表的一部分，并相应地应用合同规则。

现在，您可以为 *ACME Smile*的模板条款添加规则，例如，当订单中包含这些 SKU 时，按每笔订单支付 5%。更多详情请参阅 [为类别、SKU 或促销代码例外列表设置付款规则](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/account-administration/program-settings/exception-lists/set-payout-rules-for-exception-lists.md) 。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
