> 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-outside-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 的“匹配表达式”工具搭配使用，以识别您希望采用不同佣金支付方式的商品 SKU、类别或促销代码。

#### 括号外

您放置的正则表达式 [括号内](/brand/zh/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-inside-the-parentheses.md) 表示您希望在相应的例外列表中匹配的值。若您希望执行的不只是与 SKU、类别或促销代码列表中的项目进行精确匹配，就需要在括号外添加正则表达式。括号外的运算符会将括号中的值与传入的转化进行匹配，前提是这些转化包含相应的 SKU、类别或促销代码。

#### 示例场景

您的品牌 *ACME Auto*希望降低所有轮胎的合作伙伴佣金。 *ACME Auto* 没有完整的轮胎品牌清单，因为它计划在未来将新轮胎品牌添加到目录中。不过，您知道所有轮胎 SKU 都以 3 个字母开头（代表轮胎品牌），后接 5 个数字（例如 `ABC12345`, `DLY76565`和 `XTX85037`).

由于所有轮胎 SKU 都以 3 个字母开头，后接 5 个数字，因此您可以为这种 SKU 模式设置正则表达式，并使用“匹配表达式”工具在当前 SKU 例外列表中查找匹配项。将来， *ACME Auto* 便可按需添加其他 3 个字母的品牌代码。

#### 第 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**.
3. 选择 **添加新 SKU 列表**.
4. 输入 **列表名称**.
5. 选择 **事件类型** 以关联此 SKU 列表。

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

1. 选择 **显示高级设置** 并在 **匹配表达式** 字段中输入正则表达式。
   * 在括号内添加您要匹配的内容：
     * 添加正则表达式字符 `\w{3}` 以匹配 SKU 列表中各项目由 3 个字母组成的“文本”部分。
   * 括号外：
     * 在左括号前添加 `^` ，以断言其位于行首，确保前面没有任何字符。
     * 在右括号后添加 `\d{5}` ，这样只有当 3 个字母后面紧跟 5 个数字时，才会匹配括号中的表达式。
     * 最终表达式应为 `^(\w{3})\d{5}`.

       <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%2Fgit-blob-cd8843c09c0dd64c0fa71082298e148a3e57e18d%2F4fde8c68c10a2de3343ef0f40e7c1abca5285c0e8143ae5f2d66db0a2c0e27ea.png?alt=media" alt=""><figcaption></figcaption></figure></div>
2. 选择 **保存并添加项目**.

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

1. 通过以下两种方式之一列出您要匹配的值：
   * **手动添加项目** ，在 *SKU* 字段中输入所有现有轮胎品牌的 SKU。

     <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%2Fgit-blob-6811d8411a2314cf77dd143a143c0426a3e0151f%2Fe808470f9e8dd7f18343707c692918146215c20c064904c4fcf78cf808c94b84.png?alt=media" alt=""><figcaption></figcaption></figure></div>
   * 或者， **上传 CSV 或 Excel 文件** 并在 *SKU* 列中列出所有现有轮胎品牌的 SKU。

     * 请参阅 [创建 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="561"><figcaption></figcaption></figure></div>
2. 要添加新轮胎品牌，只需手动添加新的 SKU 列表项目，或通过上传添加。
   * 例如，为一个新的轮胎添加 **BHG123** ，其 3 个字母的品牌代码为 *BHG*.
3. 选择 **保存**.
   * 您会在 *SKU 列表* 页面上看到新建的 SKU 列表。

#### 接下来呢？

设置好正则表达式匹配规则并添加相应的 SKU 列表项目后，所有 *ACME Auto*的轮胎都会被纳入例外列表进行匹配。今后如有新的轮胎品牌（假设其 SKU 也以 3 个字母开头，后接 5 个数字），可在需要时将其添加到 SKU 列表中。任何与正则表达式匹配的传入转化都会被标记为例外列表中的项目，并据此应用合同规则。

现在，您可以为 *ACME Auto*的模板条款添加规则，例如在出现这些 SKU 时降低佣金。请参阅 [为类别、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 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-outside-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.
