正規表現テスター
無料のオンライン正規表現テストツールです。リアルタイムでの一致箇所のハイライト表示、詳細付きキャプチャグループの抽出、正規表現置換モード、50種類以上の一般的なパターンライブラリ、構文の解説機能を備えています。すべての処理はクライアント側で行われるため、データがブラウザの外に出ることはありません。
/
/
テストテキスト
試合結果
🔍 正規表現の解説
📋 Match Details (Capture Groups)
Capture group details will appear here after running a test.
📖 Common Patterns Library
📘 Regex Syntax Reference
| Pattern | Description | Example |
|---|---|---|
. | Matches any single character (except newline) | a.b matches "acb", "a2b" |
\d | Matches a digit (0-9) | \d{3} matches "123" |
\w | Matches a word character (letter, digit, underscore) | \w+ matches "hello" |
\s | Matches whitespace (space, tab, newline) | \s+ matches consecutive whitespace |
\b | Word boundary | \bword\b matches exact word |
^ | Matches start of string/line | ^Hello matches "Hello" at the start |
$ | Matches end of string/line | end$ matches "end" at the end |
* | Matches 0 or more of preceding element | ab*c matches "ac", "abc", "abbc" |
+ | Matches 1 or more of preceding element | ab+c matches "abc", "abbc" |
? | Matches 0 or 1 of preceding element (optional) | colou?r matches "color", "colour" |
{n} | Matches exactly n times | \d{4} matches 4 digits |
{n,} | Matches at least n times | \d{2,} matches 2+ digits |
{n,m} | Matches between n and m times | \d{2,4} matches 2-4 digits |
[abc] | Character set, matches any character in the set | [aeiou] matches any vowel |
[^abc] | Negated character set, matches any character NOT in the set | [^0-9] matches non-digit |
(pattern) | Capture group, extracts matched substring | (\d+) captures digit sequence |
(?:pattern) | Non-capturing group, groups without capturing | (?:\d+) groups but does not capture |
a|b | OR, matches either a or b | cat|dog matches "cat" or "dog" |
(?=...) | Positive lookahead | \d(?=px) digit followed by "px" |
(?!...) | Negative lookahead | \d(?!px) digit NOT followed by "px" |
(?<=...) | 前方参照(正) | (?<=\$)\d+先頭に「$」が付いた数字 |
(?<!...) | 負のルックビハインド | (?<!\$)\d+先頭に「$」が付いていない数字 |
正規表現とは何ですか?
正規表現(regex/regexp)とは、検索パターンを定義する文字列のことです。テキストの検索、検証、置換、データ抽出などに広く利用されています。ほぼすべての主要なプログラミング言語(JavaScript、Python、Java、PHPなど)が正規表現をサポートしています。
特長
- 試合のハイライトをリアルタイムで表示— パターンやテストテキストを入力すると、該当するすべてのマッチが即座にハイライト表示されます
- フラグの切り替え— g(グローバル)、i(大文字小文字を区別しない)、m(複数行)、s(dotAll)、u(Unicode)に対応しています
- キャプチャグループによるマッチの詳細— 各試合のポジション、内容、キャプチャグループが一目でわかる
- 置換モード— $1、$& および後方参照に対応した置換テンプレートを入力してください
- 構文の説明— 正規表現のパターンを、トークンごとに、人間が理解しやすい説明に分解する
- 50以上の一般的なパターン集— 数値の検証、文字の検証、テキスト処理、プログラミングパターン — ワンクリックで適用
- 組み込みの構文リファレンス表— よく使われるメタ文字や正規表現のルールをさっと調べる
一般的な利用例
- フォームの検証:メールアドレス、電話番号、URL、身分証明書の形式の確認
- テキストの検索と置換:特定のパターンに一致するテキストを一括置換する
- ログ分析:ログファイルからIPアドレス、タイムスタンプ、エラーメッセージを抽出する
- データ抽出:HTML、JSON、その他の構造化テキストから特定のフィールドを抽出する
- コードのリファクタリング:変数の一括リネーム、コードの書式整え直し
ヒント:まず、一般的なパターンを選択するか、正規表現を入力し、テストテキストを入力してください。結果はリアルタイムで更新されます。