> 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. 以 2 种方式中的 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.
