# 正規表現の説明

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

* regex とプロモーションコードには、主に 2 つのロジックケースがあります—`で始まる` および `で終わる`.
* この例では、プロモーションコードのベースは `SUMMER`.

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

regex は正確に `^(SUMMER).*`

と一致するプロモーションコードを自動的に照合します `SUMMER` で始まり、その他の任意の文字で終わるものです。 `SUMMER` で始まらないコードは一致しません。
{% endtab %}

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

regex は正確に `^.*(SUMMER)$`

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

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

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

#### 例

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


---

# 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/ja/nitsuitebitaidesuka/platform-features/promo-codes/regular-expression/regex-explained.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.
