コンテンツへ移動
すべてのツール

Regex Lab

利用可能

ライブマッチ、単体テスト、厳選ライブラリ、互換性分析、安全なローカル実行で正規表現を作成・検証・デバッグ・再利用します。

ローカルで実行されます。テストデータはこのブラウザの外へ送信されません。
//gm
JavaScript / ECMAScript·ブラウザのネイティブ実行
マッチのハイライトプレビュー
INFO server ready
WARN retrying request
ERROR upstream timeout
DEBUG hidden diagnostics

Regex ライブラリ

説明、サンプル、実行可能なテスト付きの厳選レシピを検索し、ワークスペースへ一式ロードできます。

Practical email address

validation · javascript

Matches a pragmatic email shape for UI validation without pretending to implement the full RFC grammar.

/^[^\s@]+@[^\s@]+\.[^\s@]+$/i
emailformsvalidation

UUID v4

validation · javascript

Matches canonical UUID version 4 strings with the correct version and variant nibble.

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
uuididentifierapi

ISO date shape

dates · javascript

Matches YYYY-MM-DD text shape. Calendar validity such as leap years still belongs to date parsing.

/\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b/g
dateisoyyyy-mm-dd

HEX color

validation · javascript

Matches three, four, six or eight digit CSS hexadecimal color values.

/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i
csscolorhexfrontend

Semantic version core

extraction · javascript

Extracts major, minor and patch numbers with optional prerelease and build metadata.

/\b(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<pre>[0-9A-Za-z.-]+))?(?:\+(?<build>[0-9A-Za-z.-]+))?\b/g
semverversionrelease

HTTP(S) URL

web · javascript

Finds HTTP and HTTPS URLs in prose. Use URL parsing for authoritative validation.

/https?:\/\/[^\s<>"]+/gi
urlhttphttpsweb

Key/value log fields

logs · javascript

Extracts simple key=value pairs and exposes key and value as named captures.

/(?<key>[A-Za-z_][\w.-]*)=(?<value>"[^"]*"|[^\s]+)/g
logskey-valueobservability

Log level

logs · javascript

Finds common application log levels as standalone words.

/\b(?:TRACE|DEBUG|INFO|WARN|ERROR|FATAL)\b/gi
logsleveldebugobservability

URL slug

validation · javascript

Matches lowercase URL slugs made of alphanumeric segments separated by single hyphens.

/^[a-z0-9]+(?:-[a-z0-9]+)*$/
slugurlrouting

IPv4 address

validation · javascript

Matches IPv4 octets from 0 to 255 without accepting over-range values.

/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/
ipnetworkipv4

JWT compact shape

extraction · javascript

Finds strings shaped like a compact three-part JWT/JWS. It does not validate signatures or claims.

/\b[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\b/g
jwttokensecurity

Double quoted string

text · javascript

Extracts double-quoted strings while allowing escaped characters inside them.

/"(?:\\.|[^"\\])*"/g
stringquotesparser

クイックリファレンス

よく使うアンカー、文字クラス、グループ、lookaround、量指定子、演算子を検索できます。

すべての token

80 件表示 · 全 80 token

\n

Newline character

パターン
\r

Carriage return character

パターン
\t

Tab character

パターン
\0

Null character

パターン
\f

Form feed character

パターン
\v

Vertical tab character

パターン
.

Any character except line terminators unless dotAll is enabled

パターン
a|b

Alternation — match either expression

パターン
\d

Any digit character

パターン
\D

Any non-digit character

パターン
\w

Any word character

パターン
\W

Any non-word character

パターン
\s

Any whitespace character

パターン
\S

Any non-whitespace character

パターン
[abc]

One character from the set

パターン
[^abc]

One character not present in the set

パターン
[a-z]

One character inside a range

パターン
[a-zA-Z]

One character from multiple ranges

パターン
[[:alnum:]]

POSIX letters and digits class

パターンpcre2
[[:alpha:]]

POSIX letters class

パターンpcre2
[[:digit:]]

POSIX decimal digits class

パターンpcre2
[[:space:]]

POSIX whitespace class

パターンpcre2
[[:word:]]

POSIX word-character class

パターンpcre2
^

Start of input, or start of line in multiline mode

パターン
$

End of input, or end of line in multiline mode

パターン
\A

Absolute start of string

パターンpcre2
\Z

End of string, or before its final line terminator

パターンpcre2
\z

Absolute end of string

パターンpcre2
\b

Word boundary

パターン
\B

Non-word boundary

パターン
\G

Start of the current match attempt

パターンpcre2
a?

Zero or one occurrence

パターン
a*

Zero or more occurrences

パターン
a+

One or more occurrences

パターン
a{3}

Exactly three occurrences

パターン
a{3,}

Three or more occurrences

パターン
a{3,6}

Between three and six occurrences

パターン
a*?

Lazy quantifier — consume as little as possible

パターン
a*+

Possessive quantifier — do not backtrack

パターンpcre2
(...)

Capturing group

パターン
(?:...)

Non-capturing group

パターン
(?<name>...)

Named capturing group

パターンjavascript
(?P<name>...)

Python-style named capturing group

パターンpython
(?>...)

Atomic non-capturing group

パターンpcre2
(?#...)

Inline comment group

パターンpcre2
(?=...)

Positive lookahead assertion

パターン
(?!...)

Negative lookahead assertion

パターン
(?<=...)

Positive lookbehind assertion

パターン
(?<!...)

Negative lookbehind assertion

パターン
\1

Match text previously captured by group 1

パターン
\k<name>

Match text captured by a named group

パターンjavascript
\k{name}

PCRE2 named backreference

パターンpcre2
\g{-1}

PCRE2 relative numeric backreference

パターンpcre2
g

Global matching

フラグjavascript
m

Multiline anchors

フラグ
i

Case-insensitive matching

フラグ
s

Dot matches line terminators

フラグ
u

Unicode-aware matching

フラグjavascript
y

Sticky matching from the current lastIndex

フラグjavascript
x

Ignore pattern whitespace and allow comments

フラグpcre2
U

Invert default greediness

フラグpcre2
$&

Insert the complete match

置換javascript
$1

Insert capture group 1

置換
$<name>

Insert a named capture group

置換javascript
$$

Insert a literal dollar sign

置換javascript
$`

Insert content before the match

置換javascript
$'

Insert content after the match

置換javascript
${1}

PCRE2 replacement capture group

置換pcre2
\p{Letter}

Match a Unicode property or script category

パターン
\P{Letter}

Negated Unicode property or script category

パターン
\X

Extended Unicode grapheme sequence

パターンpcre2
\R

Unicode newline sequence

パターンpcre2
\x20

Character by hexadecimal value

パターン
\u{1F600}

Unicode code point escape

パターンjavascript
\Q...\E

Treat enclosed text as literals

パターンpcre2
\K

Reset the reported start of the current match

パターンpcre2
(*ACCEPT)

PCRE2 control verb — immediately accept the current match

パターンpcre2
(*FAIL)

PCRE2 control verb — force the current match path to fail

パターンpcre2
(*SKIP)

PCRE2 control verb — move the next match attempt forward

パターンpcre2
(*UTF)

Enable UTF mode in PCRE2

パターンpcre2

分離された実行

JavaScript 正規表現は専用 Web Worker で厳格なタイムアウト付きで実行され、問題のあるパターンが Devary UI を停止させないようにします。

移植性を考慮した設計

対象 flavor を選択して移植性の問題を確認し、1つのエンジンがすべてのランタイムと同じように動くと偽らずにコードを生成します。

プライベートワークスペース

パターン、サンプル、テスト、インポートされた handoff はブラウザメモリ内にのみ保持され、Devary バックエンドには送信されません。

実践ガイド

具体例で正規表現をテスト・デバッグする

Regex Lab はブラウザ内の JavaScript 正規表現エンジンでサンプルテキストを照合します。名前付きキャプチャの確認方法、変更を守るテスト、他言語への移植時の注意点を説明します。

パターンから検証済みの動作へ

  1. エンジンとモードを選ぶ

    実際のマッチ処理には JavaScript / ECMAScript を選択します。Match モードで結果を確認できます。他の対象言語は互換性解析のみで、ネイティブ実行ではありません。

  2. パターンとテキストを入力する

    前後のスラッシュなしでパターンを入力し、全件検索の g や行単位のアンカーを使う m などのフラグを指定します。サンプルテキストを貼り、強調表示とキャプチャを確認します。

  3. テストで変更の影響を確認する

    Unit Tests に一致すべきケースと一致しないケースを追加します。パターンを変更したら再実行し、期待した動作が保たれているか確かめます。

再現できる例

アプリケーションログからレベルとメッセージを抽出

Match モードでログの2行を貼り付け、gm を指定します。名前付きグループ level と message が各項目を抽出します。表示結果は Regex Lab の実際の JavaScript エンジンで計算しています。

パターン

(?<level>INFO|WARN|ERROR)\s+(?<message>.+)

フラグ

gm

テストテキスト・ケース

INFO server ready
ERROR upstream timeout

期待する結果

INFO: server ready
ERROR: upstream timeout

16進数カラーコードを検証する

Unit Tests で各行を別々のケースとして追加します。最初は一致し、次は一致しない設定にします。アンカーは先頭の # を要求し、i は大文字を許容します。✓ は一致、✗ は不一致です。

パターン

^#[0-9a-f]{6}$

フラグ

i

テストテキスト・ケース

#0ea5e9
0ea5e9

期待する結果

#0ea5e9 → ✓
0ea5e9 → ✗

重要な制限

実行されるのは JavaScript のみ

照合は時間制限付きのブラウザー Worker 内で ECMAScript RegExp により行われます。同じパターンでも他の言語では動作が異なる場合があります。

互換性診断は参考情報

PCRE2、Python、Java、.NET、Go、Rust は静的なチェックとコード例のみを提供し、その言語のエンジンでは実行しません。必ず対象環境でもテストしてください。

負荷の高いパターンに注意

分離 Worker はページのフリーズを防ぐための仕組みですが、本番環境での安全性を保証しません。長い入力や意図的に厳しい入力で過度なバックトラックを検証してください。

入力データの扱い

パターンとサンプルはローカルで処理され、Devary のバックエンドにはアップロードされません。コピー、エクスポート、他サービスへの貼り付けは別の操作です。

よくある質問

g を付けると一致数が変わるのはなぜ?

g がない場合、JavaScript の検索は通常最初の一致のみを返します。g を付けると、Regex Lab は入力の末尾まで一致とキャプチャを収集します。

Python を選ぶと Python の正規表現が実行されますか?

いいえ。Python は解析対象のみです。Regex Lab は互換性上の違いを示しコード例を生成しますが、Python の re モジュールで実行・確認する必要があります。

Regex Lab はパターンの安全性を保証しますか?

いいえ。リスク診断と Worker の時間制限は補助機能です。正しさ、負荷、入力検証は実際のデプロイ環境で確かめてください。