> For the complete documentation index, see [llms.txt](https://docs-embed.anyflow.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-embed.anyflow.jp/wizard-editor/advanced-setting/text-widget-regexp.md).

# テキストの入力パターンを指定する

## 概要

テキストウィジェットに入力パターンを設定することで、パターンに沿った入力のみを受け付けることができます。

**「この項目は必ずメールアドレスにしたい」**&#x306A;どのルールがある場合にご利用ください。<br>

<figure><img src="https://files.readme.io/b8e9b66-image.png" alt="入力パターンに沿った入力をした場合" width="400"><figcaption><p>入力パターンに沿った入力をした場合</p></figcaption></figure>

<figure><img src="https://files.readme.io/f96f60e-image.png" alt="入力パターンに沿っていない入力をした場合" width="400"><figcaption><p>入力パターンに沿っていない入力をした場合</p></figcaption></figure>

## 設定方法

ウィザードエディタにて、入力方法を「テキスト」にした際に利用できます。

右下の設定フィールドにある「入力パターン」に正規表現を記述することで、\
その正規表現に一致したエンドユーザー入力のみを受け付けます。\
正規表現に一致しないエンドユーザー入力が行われたときのエラーメッセージも指定できます。

なお、この仕組みはHTML属性の「[pattern](https://developer.mozilla.org/ja/docs/Web/HTML/Attributes/pattern)」を利用しています。\
パターンの正規表現は、部分文字列に一致させるのではなく、入力の value 全体に一致させる必要があります。\
パターンの始めに `^(?:` が、終わりに `)$` が含まれているかのように扱われます。

<figure><img src="https://files.readme.io/cb6de3a-image.png" alt="メールアドレスの入力のみを受け付ける例"><figcaption><p>メールアドレスの入力のみを受け付ける例</p></figcaption></figure>

{% hint style="success" %}

### ヒント

正規表現を指定していない場合は、すべてのエンドユーザー入力を受け付けます。
{% endhint %}

## 設定例

* 氏名（半角スペース区切り）：`[a-zA-Z\u3040-\u30FF\u4E00-\u9FFF]+( [a-zA-Z\u3040-\u30FF\u4E00-\u9FFF]+)+`
* メールアドレス：`[^\s@]+@[^\s@]+\.[^\s@]+`
* URL：`https?:\/\/[^\s]+`
  * 使用できる文字を制限した例：`https?:\/\/[a-zA-Z0-9\-._~:\/?#@!\$&'\(\)\*\+,;=%]+`
* 電話番号：`\d{2,4}-\d{1,4}-\d{4}`
* 正の整数：`\d+`
* 小数：`\d+(\.\d+)?`
* ブール値：`true|false`
* 日付：`\d{4}-\d{2}-\d{2}`
* 日時：`\d{4}-\d{2}-\d{2} \d{2}:\d{2}`


---

# 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://docs-embed.anyflow.jp/wizard-editor/advanced-setting/text-widget-regexp.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.
