LocalExcelTool
Get started

Regex Tester

Write a regex and see matches instantly, with capture groups and positions.

Runs in your browserNo account neededFree

What is Regex Tester

A regex tester applies a regular expression pattern to a string and shows where it matches. Enter a pattern, flags and test text to see the match count, positions and capture groups.

🔒 Everything runs in your browser. Nothing is uploaded.

What this tool actually does with your file

Where it runs
In your browser, on this page
Upload
None — the file never leaves your device
Offline
Works with the network disconnected

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.

How to use it

  1. 1.Enter a regex pattern
  2. 2.Add flags and test text
  3. 3.Inspect the matches

How Regex Tester works under the hood

Text tools look trivial until encoding enters the picture. The bytes are unambiguous; the characters they represent are a guess unless the encoding is declared.

  1. 1

    Read bytes, not characters

    The file is read as an ArrayBuffer so the original bytes are preserved, including a byte-order mark if present.

  2. 2

    Decode with a declared or detected encoding

    TextDecoder converts bytes to text. UTF-8 is validated; a BOM is used when present; legacy encodings must be chosen explicitly because guessing between GBK and Shift_JIS is unreliable.

  3. 3

    Transform as a pure function

    Escaping, quoting, case changes and line-ending normalisation are applied to the decoded string, so the same input always gives the same output.

  4. 4

    Encode and download

    The result is encoded back to UTF-8 (or the format's own escaping rules) and returned as a Blob.

  5. Processing pipeline

Why a file looks like mojibake

Mojibake is the same bytes decoded with the wrong table: Shift_JIS read as UTF-8, or GBK read as Latin-1. Nothing is corrupted in the file itself. If the output is garbled, the fix is to re-run with the correct source encoding, not to edit the text by hand — editing bakes the wrong characters in permanently.

CSV quoting is not optional

A CSV field containing a comma, a quote or a newline must be wrapped in double quotes, and inner quotes doubled. Tools that skip this produce files that look fine until someone imports them and the columns shift. This converter applies RFC 4180 quoting on output.

Where text tools stop

There is no reliable way to detect an unknown legacy encoding from content alone, and no way to recover bytes that were already lost. Mixed encodings inside one file cannot be fixed automatically. Very large inputs are capped because regular expressions and repeated string concatenation can take quadratic time.

Verify it yourself

Text is transformed in memory. Nothing is sent while it runs.

  1. 1.Open DevTools on this page and switch to the Network tab
  2. 2.Keep the filter on Fetch/XHR and run the tool
  3. 3.Confirm no request carries your file — you should see only page assets and fonts

Frequently asked questions

Which flags are supported?

JavaScript regex flags such as g, i, m, s and u. You can combine them.

How are matches shown?

You get the match count, start/end positions and capture groups.

Is input uploaded?

No. Matching uses the browser's built-in RegExp.

What this kind of conversion cannot keep

Text tools never leave the page: the string you paste is transformed in memory and written back to the result box. There is no request, no log and no retention, which also means there is no way to recover a value you closed the tab on.

More in Text