Skip to main content

Regex Tester & Pattern Library

Test JavaScript regular expressions with common starter patterns

Quick Samples:

Load a starter pattern, then check its behavior against your own text.

Toggle flags:
0 chars

Patterns are limited to 2,000 characters and test text to 100,000; each run stops after 2 seconds.

Matches
0 matches
<none>

Was this Regex Tester & Pattern Library helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with Regex Tester & Pattern Library

  • Test regex against text
  • Find pattern matches
  • Browse common regex patterns

How this text processing works

Choose from seven built-in JavaScript regex patterns or write a custom expression, test it against text, and inspect each full match and its start index.

Example input

Pattern: \d+, flags: g, text: a1b22

Example output

[1] 1 and [3] 22 — each match listed with its zero-based start index

Practical workflow

  1. Choose one of the seven starter patterns from Pattern library, or type a JavaScript expression without surrounding slashes.
  2. Set flags in the separate field: g lists every match, i ignores letter case, m changes line-anchor behavior, s lets a dot match line breaks, and u enables Unicode mode.
  3. Enter sample text and select Test Regex; each full match appears as [index] text, or the result shows <none>.
  4. Review the selected preset's description and limits, then copy the pattern when it fits your use case.

Common use cases

  • Start with the email, URL, US phone, date-shape, IPv4, hex-color, or password example before adapting a validation expression.
  • Find the character offsets of matching IDs, digits, or other tokens in a log line or pasted text sample.
  • Compare global and single-match behavior while learning how JavaScript flags affect a pattern.

Important notes and limitations

  • Matching runs in your browser with the JavaScript RegExp engine, so results reflect JS semantics — not PCRE, Python, or Java.
  • Without g, the tester reports the first match only. A missing g flag is valid and is not an error.
  • The seven library entries are starter patterns, not complete standards validators. In particular, the date expression checks YYYY-MM-DD shape but can match an impossible calendar date; the email and URL expressions also have format limits.
  • The password pattern checks for at least eight characters with an ASCII letter and digit; it does not measure strength or check breached-password lists.
  • Only the full match and its zero-based start index are shown; capture groups are not broken out. Patterns run in a Web Worker with a 2-second deadline, pattern and text limits of 2,000 and 100,000 characters, and a 10,000-match result cap. A timed-out worker is stopped without blocking the page.

Terminal & CLI equivalents

ripgrep fast regex search

rg -P "(?<=id=)\d+" server.log

Lightning-fast grep alternative with PCRE2 lookaround and regex support.

GNU grep with PCRE pattern

grep -P -o "^[A-Z][a-z0-9_]+" data.txt

Matches Perl-compatible regular expressions directly in Linux shell environments.

Regular Expression Engine Dialect Matrix

FeatureJavaScript (ECMA-262)PCRE2 (PHP / grep -P)Python (re module)Go (RE2)
Lookbehind AssertionsYes (ES2018+)Full variable supportFixed length only in std reNo support (RE2 design)
Named Capture Groups(?<name>pattern)(?P<name>pattern)(?P<name>pattern)(?P<name>pattern)
Possessive QuantifiersNoYes (e.g. a++)In regex moduleNo
ReDoS Catastrophic BacktrackingVulnerable (NFA)Vulnerable unless JITVulnerable (NFA)Immune (Linear time guarantee)

Common errors & troubleshooting

Catastrophic Backtracking / Regular Expression Denial of Service (ReDoS)

Cause: Nested quantifiers such as (a+)+$ cause exponential branch exploration on non-matching inputs.

Solution: Refactor patterns into non-overlapping character classes or atomic groupings.

Continue your workflow

  • Regex Visualizer — visualize regular expressions as state transition railroad diagrams.
  • String Escaper — escape regex special characters for safe inclusion in programming code.
  • Diff Checker — verify regex replacement outputs side by side with original inputs.
  • Text Utilities — clean and transform text strings with case conversion and trimming.

Frequently asked questions

Why do I get “Invalid regex” for a pattern that works elsewhere?

The pattern may use syntax unsupported by JavaScript or by the browser's RegExp version, or the flags may be invalid or repeated. The g flag is optional; without it the tool reports only the first match.

Do I need to include the slashes?

No. Enter only the pattern, for example \d{4}-\d{2}, and put the flags in the separate field.

Do the date and email presets validate every possible value?

No. They are starter expressions. The date preset checks string shape but not calendar validity, and the email preset does not cover every address allowed by email standards.

Does the result show captured groups separately?

No. Results list each whole match and its zero-based start index; capture-group values are not displayed as separate rows.