Skip to content

Regex Tester

Test expressions with isolated execution, match highlighting, and capture groups.

Local, available offline

4,096 character pattern limit0

Flags

1 MiB · 1,000 match limit0 characters

Live tests run after a short pause. Every run uses a fresh worker and is terminated after two seconds.

Matches

Enter a pattern and test text to begin.

No result yet

Enter a pattern or load the sample. Matches will be highlighted without executing anything on the main thread.

Working notes

Use Regex Tester with the boundary visible.

Regex Tester runs JavaScript regular expressions in an isolated worker and presents bounded matches and capture groups without executing user-supplied code.

What is Regex Tester?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regular expressions are used in virtually every programming language and text editor to find, match, replace, and validate strings. They range from simple literal patterns (find every occurrence of "error") to complex constructions with quantifiers, character classes, groups, lookahead, and lookbehind assertions. The JavaScript regex engine supports named capture groups, Unicode property escapes, and the v flag for set operations in character classes. A regex tester lets you develop and debug patterns interactively: type a pattern, paste test text, and instantly see which parts match and what each capture group contains. This feedback loop is essential because regex syntax is dense and a single misplaced quantifier can change the meaning entirely. StackCache runs the pattern in an isolated Web Worker with a time limit, so even a pattern with catastrophic backtracking is safely cancelled instead of freezing your browser tab.

When to use it

  • Validating user input — build and test patterns for email addresses, phone numbers, postal codes, or custom identifiers before embedding them in your application.
  • Parsing log files — write patterns to extract timestamps, error codes, IP addresses, or request IDs from unstructured log lines.
  • Search-and-replace refactoring — prototype a pattern with capture groups before using it in a global find-and-replace across your codebase.
  • Writing data extraction pipelines — test patterns that pull structured data from HTML, CSV, or plain text before committing them to a scraping or ETL script.
  • Learning regex — experiment with metacharacters, quantifiers, and assertions with immediate visual feedback on what matches and what does not.

How to use it

  1. 01Enter a regex pattern in the pattern field. Use JavaScript syntax (e.g. \d+, [A-Za-z], (?<name>...)).
  2. 02Set flags: g (global), i (case-insensitive), m (multiline), s (dotall), u (unicode), or v (unicode sets).
  3. 03Paste or type test text in the input area.
  4. 04Matches are highlighted in the test text as you type. Each match shows its index, full text, and named or numbered capture groups.
  5. 05If the pattern causes catastrophic backtracking, the worker is cancelled after the time limit and a timeout warning is shown.

Common mistakes

  • Forgetting to escape special characters — characters like . * + ? ( ) [ ] { } ^ $ \ | have special meaning. To match them literally, escape with a backslash: \. \* \+.
  • Greedy vs lazy quantifiers — .* is greedy and matches as much as possible. Use .*? for the shortest match. This matters especially when matching HTML tags or quoted strings.
  • Catastrophic backtracking — nested quantifiers like (a+)+ or (a|aa)* can cause exponential matching time on certain inputs. Rewrite with atomic groups or possessive quantifiers.
  • Anchoring patterns — without ^ and $ (or \b for word boundaries), a pattern matches anywhere in the string. If you need a full-string match, anchor both ends.
  • Overlooking the global flag — without g, only the first match is returned. Use g to find all matches, but be aware that lastIndex advances between calls to exec().

Synthetic example

Capture a service identifier

Input

Pattern: service-(?<id>\d+)
Text: service-204 is ready

Result

Match: service-204
Group id: 204

Regex flavors across languages

FeatureJavaScriptPythonGoPCRE (PHP/Perl)
Named groups(?<name>)(?P<name>)Not supported(?P<name>) or (?<name>)
LookbehindVariable-lengthVariable-lengthNot supportedFixed-length only
Unicode properties\p{L} (u/v flag)\p{L} (default)Limited\p{L}
Atomic groupsNot yetNot yetNot supported(?>...)
Multiline default^ $ match start/end. excludes \n. excludes \n. excludes \n
Set operationsv flag ([A--B])Not supportedNot supportedNot supported

Related standards

Limits and data boundary

  • Syntax and behavior follow the browser JavaScript regular-expression engine.
  • Execution is bounded and may time out for pathological patterns.

Frequently asked questions

Which regex engine does this tester use?
It uses the JavaScript RegExp engine built into your browser, which supports named capture groups, lookahead, lookbehind, and Unicode property escapes.
Does the tool execute my code?
No. Only the regular expression is compiled and matched against your test text. No arbitrary JavaScript runs.
What happens with catastrophic backtracking?
The evaluation runs in an isolated worker with a time limit. If a pattern takes too long, execution is cancelled and a timeout is reported.
Can I use this tool to test regex for Python or Go?
The core syntax (character classes, quantifiers, groups) is similar across languages, but named group syntax, lookbehind support, and flag behavior differ. Test the final pattern in your target language.
What are the regex flags?
g (global, find all matches), i (case-insensitive), m (multiline, ^ and $ match line boundaries), s (dotall, . matches newlines), u (Unicode, enables \p{} escapes), and v (Unicode sets, enables set operations in character classes).