# Regex Inside the Parentheses

[Regex](https://help.impact.com/brand/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained) (or Regular Expression) is a type of code you can use when you want to match a portion of the characters in your uploaded product SKUs, categories, or promo codes with the values that are passed to impact.com with conversions. You can use regex with impact.com's Match Expression tool to identify product SKUs, categories, or promo codes for which you want to pay out differently.

#### Inside the parentheses

By placing part of a regex inside parentheses, you can group that part of the regex together. The Match Expression tool can then extract the values you place between the brackets and find a match in the accompanying exception list items you provide. The items you add to the exception list should exactly match the regex between the parentheses so that the regex [outside the parentheses](https://help.impact.com/brand/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-outside-the-parentheses) can be applied to the whole list.

#### Example scenario

Your brand, *ACME Smile*, would like to pay out 5% to partners when a customer purchases any dental product. *ACME Smile* doesn't have a comprehensive list of SKUs for all dental products, because your brand is constantly removing products and adding new ones. However, you do know that all dental product SKUs start with either TOOTH, SMILE, or SHINE (e.g. `SHINE98763`, `SMILE987abc`, `TOOTH65abc64`).

Because all dental SKUs start with TOOTH, SMILE, or SHINE, you can set up a regex for dental product SKUs in general, and use the Match Expression tool to find matches in an incomplete SKU exception list, as demonstrated in the following sections.

#### Step 1: Create a SKU list

1. From the top navigation bar, select ![](https://4048883401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-1183576591b45997efe4dc81a25024640591d02a%2F245137dc972a7a7f6165b59538fcdbac8fd5bd8fee4ba9f20c1a2982c5b58b57.svg?alt=media) **\[User profile] → Settings**.&#x20;
2. On the right, under the *Exception Lists* section, select **SKU**.
3. Select **Add New SKU List**.
4. Enter a **List Name**.
5. Select the **event type** you want to associate with this SKU list.

#### Step 2: Set up the regex

1. Select **Show advanced settings** and enter your regex in the **Match Expression** field.
   * Inside parentheses, add only the values for which you want to match:
     * Add the 3 character strings that we know dental SKUs start with, separated by the regex character `|` which means OR.
   * Outside the parentheses, add any regex that helps refine your match:
     * Add the regex character `^` before the opening parentheses to assert the position at the start of the line, ensuring that there are no preceding characters.
     * Add the regex character `.` after the closing parentheses to match for any following characters (e.g., numerals, letters, hyphens) except for line terminators.
     * Add the regex character `*` after the period to look for any number of matches (i.e., between 0 and unlimited matches).
   * The final expression should be `^(TOOTH|SMILE|SHINE).*`.
2. Select **Save and Add items**.

   <div data-with-frame="true"><figure><img src="https://4048883401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-4bb3629be1ac22f2b65c077226c453d65f678808%2F5dcc5964a43131b9e5d85ad177edda759fccdd0ddcd5ee6f92e3ee24037c186c.png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### Step 3: Add exception list items

1. List the values you want to match in 1 of 2 ways:
   * **Add Items manually** by entering TOOTH, SMILE, and SHINE in the *Sku* fields.

     <div data-with-frame="true"><figure><img src="https://4048883401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-a3e20e2c8aa2237a4597a5ac0a0cbd74c41bd1cd%2Fcec97e09eaf48146d9f067164c5413dea24278ba599777d9eec105611757130d.png?alt=media" alt=""><figcaption></figcaption></figure></div>
   * Alternatively, **Upload a CSV or Excel file** listing TOOTH, SMILE, and SHINE under the *SKU* column.

     * See [Create a SKU exception list](https://help.impact.com/brand/account-administration/program-settings/exception-lists/create-category-and-sku-exception-lists#create-a-sku-exception-list-0-4) for more information.

     <div data-with-frame="true"><figure><img src="https://4048883401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwMLlMoFBtKJa8ptd3zaw%2Fuploads%2Fgit-blob-eb37bee763ecfd4e78e87fe7f210deae7f227fbd%2F8796bd6da4b37325a3a07d395cd862ce446a4ad4901543e30f868b38c04cb0f0.png?alt=media" alt=""><figcaption></figcaption></figure></div>
2. Select **Save**.
   * You'll see your new SKU list on the *SKU Lists* screen.

#### What next?

Now that you've set up a regex Match Expression and added the 3 SKU list items, all *ACME Smile*'s future dental products (assuming they also have SKUs starting with TOOTH, SMILE, or SHINE) will be matched as part of the exception list. Any incoming conversions that match the regex will be flagged as part of the exception list and contract rules will be applied accordingly.

Now you can add rules to *ACME Smile*'s template terms, such as paying out 5% per order whenever these SKUs are present. See [Set payouts for a SKU exception list](https://help.impact.com/brand/account-administration/program-settings/exception-lists/create-category-and-sku-exception-lists#set-payouts-for-a-sku-exception-list-0-5) for more details.


---

# Agent Instructions: 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:

```
GET https://help.impact.com/brand/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-inside-the-parentheses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
