> 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/ja/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.md).

# 正規表現の説明

Regex（正規表現）とは、一般的なケースに一致するテキストを照合するために使えるコードで、プロモコードの照合に便利です。Regex は大文字・小文字を区別するため、プロモコードに一致するように regex を設定してください。

* Regex とプロモコードには、主に 3 つのロジックケースがあります： `〜で始まる`, `〜で終わる`、および `含む`.
* この例では、プロモコードのベースは `SUMMER`.

{% tabs %}
{% tab title="で始まる" %}
パートナーに夏のプロモコードを一連発行しました、 `SUMMER20OFF`, `SUMMER10`、および `SUMMER25`。それらすべてを照合してパートナーにクレジットするには、どうすればよいでしょうか？ そこで使うのが、 `〜で始まる` のロジックです。ベースのプロモコードの末尾にピリオドとアスタリスクを追加するだけです。

正規表現は次のとおりです： `^(SUMMER).*`

これにより、次で始まるすべてのプロモコードが自動的に一致します： `SUMMER` および、他の任意の文字で終わるものが対象です。次で始まらないコードは `SUMMER` 一致しません。
{% endtab %}

{% tab title="〜で終わる" %}
パートナーに夏のプロモコードを一連発行しました、 `20OFFSUMMER`, `10SUMMER`、および `25SUMMER` プロモコードが常に次で終わる場合 `SUMMER`。それらを一致させるにはどうすればよいでしょうか？ そこで使うのが、 `〜で終わる` のロジックです。ベースのプロモコードの先頭にピリオドとアスタリスクを追加し、文字列のアンカーを指定するために $ を追加します。

正規表現は次のとおりです： `^.*(SUMMER)$`

これにより、他の文字で始まり、次で終わるすべてのプロモコードが自動的に一致します： `SUMMER`。次で終わらないコードは `SUMMER` 一致しません。
{% endtab %}

{% tab title="含む" %}
パートナーに夏のプロモコードを一連発行しました、 `20SUMMER`, `SUMMER20OFF`、および `EXTRASUMMER10`、ここで `SUMMER` コード内のどこかに現れます。そこで使うのが、 `含む` のロジックです。追加してください `.*` ベースのプロモコードの前後に追加し、式全体を ^ と $ のアンカーで囲みます。

正規表現は次のとおりです： `^.*(SUMMER).*$`

この正規表現は、次を含むプロモコードに一致します： `SUMMER` コード内の任意の場所に。次を含まないコードは `SUMMER` 一致しません。
{% endtab %}
{% endtabs %}

より複雑な式については、CSM に連絡するか、 [サポートにお問い合わせください](https://app.impact.com/support/portal.ihtml?createTicket=true\&accountType=ADVERTISER) 。

{% hint style="success" %}
**注：** Regex の大文字・小文字の区別は、次を追加することで解除できます： `(?i)` の後に `^` を regex に追加します。
{% endhint %}

## 例

```programlisting
^(?i)(SUMMER).*
```


---

# 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/ja/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.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.
