LocalExcelTool
はじめる

正規表現テスト

正規表現を書いて、その場でマッチを確認。グループも見えます。

正規表現テストとは

正規表現テストとは、正規表現パターンを文字列に当てて一致箇所を確認する処理です。パターン・フラグ・対象文字列を入れるだけで、一致回数と位置、キャプチャグループを表示します。

🔒 処理はすべてブラウザ内で完結し、データは送信されません。

このツールの前提

処理場所
このページのブラウザ内(JavaScript / Canvas)
アップロード
なし — ファイルは端末の外に出ません
オフライン
ページを開いた後は通信不要

It runs JavaScript's engine, with JavaScript's rules

The pattern is compiled with new RegExp, so it follows ECMAScript semantics — not PCRE, not Python's re, not Go's RE2. Named groups are (?<name>…), lookbehind (?<=…) and (?<!…) are supported in current engines, but atomic groups (?>…) and possessive quantifiers (a++) are not, and \p{…} requires the u flag.

The practical consequence is that a pattern copied from a PHP or Python codebase may behave differently or not compile at all. The error message names the offset where compilation failed, which usually points straight at the unsupported construct.

Catastrophic backtracking is a real hazard

A nested quantifier such as (a+)+b, run against a long string of a's that does not end in b, takes exponential time. The tab freezes, and no error is raised because nothing is wrong with the pattern — it is the search space that explodes. Any regex that will run on user input needs to be checked against this.

The fixes are structural: replace (a+)+ with a+ where the nesting adds nothing, use atomic grouping or possessive quantifiers where the engine allows, or anchor the pattern. When the engine has no such support, the safe move is to bound the input length and run the match outside the request path.

Reading the result correctly

With the g flag, lastIndex persists between calls on the same object, so repeated .test() calls alternate true and false — a classic bug. This tester creates a fresh instance per run, which is why the result does not flicker here but may in your own code.

For patterns with groups, the output shows numbered and named captures plus their indices. Remember that an optional group that did not participate is undefined rather than empty string, and that a zero-length match is still a match — validate the captured values, not just whether something matched.

使い方

  1. 1.正規表現パターンを入力
  2. 2.フラグとテスト文字列を入力
  3. 3.一致結果を確認

他の方法との比較

同じ変換をする方法は 3 つあります。ブラウザ内(このページ)、サーバー側の変換サービス、デスクトップアプリ。差がつくのは速度ではなく、ファイルがどこへ行くかと、無料でどこまでできるかです。

観点このツールサーバー側の変換サービス
ファイルの処理場所このページのブラウザ内ベンダーのサーバー(アップロード後)
アカウント不要多くの場合必要(無料枠の制限解除に登録を求める)
無料で扱えるサイズサイズ制限なし(回数制限もなし)数ファイル/時間、または 5〜10MB 程度で課金 wall
料金無料。Pro は月 $9(大きいファイルと AI 機能のみ)サブスクが一般的。おおむね月 $7〜15(2026 年 11 月時点)
オフライン一度開けば通信不要不可
20MB を処理し始めるまで待ち時間なし(アップロードが無い)アップロードが支配的(10Mbps 上りで約 16 秒)
保証できないこと何も保存されないため、閉じたタブの内容は復元できません同じ(変換の原理は変わらない)

サーバー側のサービスが優れている点は明確にあります。巨大なファイル、チームでの共有、変換履歴の管理、スクリプトからの自動化。逆に「1 回だけ、手元のファイルを別形式にしたい」という今回の用途では、アップロードの待ち時間と登録の手間だけが増えます。

よくある質問

どのフラグが使えますか?

JavaScript の正規表現フラグ(g・i・m・s・u など)が使えます。複数同時に指定できます。

一致箇所はどのように表示されますか?

一致回数、開始・終了位置、キャプチャグループを一覧で表示します。

入力は送信されますか?

いいえ。ブラウザ内の RegExp で処理します。

この変換で失われるもの

テキストツールはページ外に出ません。貼り付けた文字列はメモリ上で変換され、結果欄に書き戻されます。リクエストもログも保持もないため、タブを閉じた値を復元する方法もありません。

その他のテキスト処理