> 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、またはRegular Expression）とは、一般的な条件でテキストを照合するために使えるコードで、プロモコードの照合に便利です。正規表現では大文字と小文字が区別されるため、プロモコードに一致するよう、大文字と小文字を正しく設定してください。

* 正規表現とプロモコードの照合には、主に次の3つのロジックがあります。 `starts with`, `ends with`、および `contains`.
* この例では、プロモコードの基本部分は `SUMMER`.

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

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

これにより、 `SUMMER` で始まり、その後に任意の文字が続くプロモコードがすべて自動的に照合されます。 `SUMMER` で始まらないコードは照合されません。
{% endtab %}

{% tab title="次で終わる" %}
パートナー向けに夏のプロモコードをいくつか発行しました。たとえば、 `20OFFSUMMER`, `10SUMMER`、および `25SUMMER` があり、プロモコードは常に `SUMMER`で終わります。これらを照合するにはどうすればよいでしょうか？ここでは `ends with` ロジックを使います。基本となるプロモコードの先頭にピリオドとアスタリスクを追加し、文字列の末尾を指定するために $ を追加します。

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

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

{% tab title="含む" %}
パートナー向けに夏のプロモコードをいくつか発行しました。たとえば、 `20SUMMER`, `SUMMER20OFF`、および `EXTRASUMMER10`があり、 `SUMMER` がコード内のどこかに含まれています。ここでは `contains` ロジック。 `.*` 基本のプロモーションコードの前後に追加し、式を ^ と $ のアンカーで囲みます。

正規表現は次のとおりにしてください。 `^.*(SUMMER).*$`

この正規表現は、次の文字列を含むプロモーションコードに一致します。 `SUMMER` コード内のどこかに `SUMMER` が含まれないコードには一致しません。
{% endtab %}
{% endtabs %}

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

{% hint style="success" %}
**注:** 正規表現の大文字と小文字の区別をなくすには、 `(?i)` の後に `^` を正規表現に追加します。
{% 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.
