RegEx テスター
定期的にテストとデバッグを行う 式
一致は見つかりません
一般的なパターン
通常とは 表現?
正規表現 (regex または regexp) は、文字の組み合わせを照合するために使用されるパターンです。 文字列。これらは、検索、検証、抽出、および分析を行うための非常に強力なツールです。 テキストを置き換えます。正規表現はもともと 1950 年代に開発され、現在ではほぼすべての言語でサポートされています。 プログラミング言語とテキストエディター。
このツールは、ECMAScript 標準を実装する JavaScript の正規表現エンジンを使用します。テストしてください パターンをコード内で使用する前にここで確認してください。すべての処理はデータなしでブラウザ内で行われます。 サーバーに送信されます。
正規表現構文クイックリファレンス
文字 クラス
\d- Any digit (0-9)\w- Word character (a-z, A-Z, 0-9, _)\s- Whitespace (space, tab, newline).- Any character except newline[abc]- Any of a, b, or c[^abc]- Not a, b, or c
量子子
*- 0 or more+- 1 or more?- 0 or 1 (optional){n}- Exactly n times{n,}- n or more times{n,m}- Between n and m times
アンカー & 境界
^- Start of string/line$- End of string/line\b- Word boundary\B- Non-word boundary
グループと 代替
(abc)- Capture group(?:abc)- Non-capture groupa|b- Either a or b\1- Backreference to group 1
フラグについて
よくある質問
なぜエスケープする必要があるのですか バックスラッシュ?
In JavaScript strings, backslash is an escape character. To include a literal backslash in a
regex pattern from a string, you need \\. For
example, \\d
in a string becomes \d in the
regex.
が必要です。違いは何ですか *と+の間?
* matches
zero or more occurrences (can match nothing). + requires at
least one occurrence. For example, a* matches "",
"a", "aaa", while a+ only
matches "a", "aaa".
リテラルを照合するにはどうすればよいですか ピリオドまたは括弧?
Special regex characters need to be escaped with a backslash. To match a literal period, use
\.. For
brackets: \[
and \].
Characters that need escaping: . * + ? ^ $ { } [ ] \ | ( )
を使用します。 似合いすぎ?
Regex quantifiers are "greedy" by default—they match as much as possible. Add ? after a
quantifier for "lazy" matching (e.g., .*? instead of
.*).
一般的な使用例の追加
- フォーム検証: 電子メール、電話の検証 数値、URL、カスタム形式
- 検索と置換: 検索と変換 エディターとコードのテキスト パターン
- ログ解析: タイムスタンプ、IP、 ログ ファイルからのエラー コード
- データ抽出: 特定のデータを取得します HTML、JSON、または非構造化テキストから
- 入力サニタイズ: 削除またはエスケープ 危険な文字