> 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 とプロモコードには、主に2つのロジックがあります—`〜で始まる` および `〜で終わる`.
* この例では、プロモコードのベースは `SUMMER`.

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

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

これにより、 `SUMMER` で始まり、後ろに他の任意の文字が続くプロモコードが自動的に一致します。 `SUMMER` で始まらないコードは一致しません。
{% endtab %}

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

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

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

で終わらないコードは一致しません。 [サポートに連絡してください](https://app.impact.com/support/portal.ihtml?createTicket=true\&accountType=ADVERTISER) より複雑な式については、CSMまたは

{% hint style="info" %}
**注：** までお問い合わせください。 `(?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 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/ja/what-would-you-like-to-learn-about/platform-features/promo-codes/regular-expression/regex-explained.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.
