Regex Tester

Test regular expression matches

Flags ?
Test Text
Matches
No matches

Tool guide

About Regex Tester

A regex tester runs JavaScript regular expressions against text and shows live matches, capture groups, and match indices.

Use it to debug email, URL, log-line, extraction, and form-validation patterns locally in the browser.

How to use the Regex Tester

  1. Enter a regular expression without wrapping / /.
  2. Enable g, i, m, s, u, or y flags as needed.
  3. Paste test text and inspect each match, capture group, and index.

When you would use it

  • Check whether a form-validation pattern rejects valid input.
  • Extract IDs, URLs, or error codes from logs and text.
  • Compare greedy and lazy quantifiers to control match length.

Flags, capture groups, and common traps

JavaScript regex is sensitive to flags, escaping, and quantifiers. A missing backslash or broad .* can change the result completely.

  • g returns all matches; without it you usually inspect the first match.
  • i ignores case, and m makes ^ and $ work per line.
  • Parentheses create capture groups; (?: ) avoids captures you do not need.
  • Heavy backtracking can slow long text, so avoid deeply nested quantifiers.

Regex Tester FAQ

Should I type /pattern/g?
No. Enter only the pattern and set flags in the separate controls.
Why is the match longer than expected?
.* and .+ are greedy by default. Try .*? or a more specific character class.
Is my test text uploaded?
No. Matching runs locally in the browser and is not uploaded to wetool.site.

Regex Tester vs production validation

A tester is fast feedback, but production validation still needs edge cases, empty values, Unicode input, and checks against the regex engine used by your backend.

Catastrophic backtracking checklist

A regex that works on a short sample can still hang on long input. Before shipping, inspect nested quantifiers and broad wildcards.

  • Avoid explosive nested or overlapping patterns such as (.*)+, (.+)+, or (a|aa)+.
  • Use explicit character classes instead of .* when possible; for example, prefer [^,]* for a comma-delimited field.
  • Limit user-controlled input length and set server-side timeouts or use a regex engine with safe execution controls.

JavaScript regex vs other language engines

Passing in an online tester does not guarantee a backend engine will behave the same. Flags, lookbehind, Unicode, and named captures differ across engines.

  • JavaScript g, i, m, s, u, and y flags do not map perfectly to PCRE, Python, or Go options.
  • Lookbehind, Unicode property escapes, and named groups may be unavailable in older browsers or some backend runtimes.
  • Before moving a pattern to the backend, cover empty values, long input, emoji, and newline cases with target-language unit tests.