> 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) （或 Regular Expression）是一种代码类型，当你想将上传的产品 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 例外列表中查找匹配项，如下节所示。

{% 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. 选择 **显示高级设置** 并在 **Match Expression** 字段中输入你的正则表达式。
   * 在括号内，只添加你想匹配的值：
     * 添加我们已知牙科 SKU 开头的 3 个字符串，用正则表达式字符 `|` 分隔，这表示 OR。
   * 在括号外，添加任何有助于细化匹配的正则表达式：
     * 添加正则表达式字符 `^` 在左括号前，用于声明行首位置，确保前面没有任何字符。
     * 添加正则表达式字符 `.` 在右括号后，用于匹配后续任何字符（例如数字、字母、连字符），但不包括行结束符。
     * 添加正则表达式字符 `*` 在句点后，用于查找任意数量的匹配项（即从 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. 你可以通过以下 2 种方式之一列出想要匹配的值：
   * **手动添加项目** 在 *Sku* 字段中输入 TOOTH、SMILE 和 SHINE。<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 例外列表](/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 %}

#### 接下来呢？

现在你已经设置了正则表达式 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/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 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.
