Developer Tools

Regex Tester

Test JavaScript regular expressions with highlighted matches, capture groups and a timeout that stops runaway patterns.

Loading tool…

How to use the Regex Tester

  1. Type a pattern without the surrounding slashes, or click one of the examples to fill everything in.
  2. Tick the flags you need. “g” finds every match; without it only the first match is reported.
  3. Paste or type the test string. Matches are highlighted as you type.
  4. Check the match list for each match’s position and its numbered and named capture groups.

Good to know

  • This uses your browser’s own JavaScript (ECMAScript) regular-expression engine, so results match what JavaScript code would produce. Other languages (PCRE, Python, .NET) differ in some syntax.
  • Matching runs in a separate Web Worker with a 1.5-second limit. If a pattern runs longer, for example a nested quantifier such as (a+)+$ against a long string of a’s that fails to match, the worker is stopped and a message explains why. The limit protects the page from freezing; it cannot make a pathological pattern fast.
  • If your browser cannot start a worker (some restricted or very old browsers), the tool shows an error instead of running the pattern on the page itself.
  • Limits: patterns up to 500 characters, test strings up to 100,000 characters and 1,000 reported matches. Beyond that you are told, not silently cut off.
  • Indexes are JavaScript string positions (UTF-16 code units), so an emoji counts as two positions.
  • Empty matches (such as from the pattern a*) are listed but not highlighted. The “d” (indices) and “y” (sticky) flags follow standard JavaScript behaviour; “v” appears only where the browser supports it and cannot be combined with “u”.
  • Syntax errors are reported using the browser’s own message as soon as you type.

Examples

Dates with named groups
Pattern (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) with flag g on “Released 2024-03-15” gives one match with year = 2024, month = 03, day = 15.
Case-insensitive hex colours
Pattern #(?:[0-9a-f]{3}){1,2}\b with flags gi finds #0B2B67, #ff5b00 and #FFF in the same sentence.
Unicode letters
Pattern \b\p{Lu}\p{L}* with flags gu matches capitalised words including accented ones, such as Édith, Zoë and Köln.

Frequently asked questions

Is my test text sent anywhere?

No. The pattern and text are passed to a worker that runs inside your own browser. Nothing is uploaded or stored.

Why did I only get one match?

Without the g (global) flag, a JavaScript regex stops at the first match. Tick g to find all of them.

What does “pattern took too long” mean?

The engine was still trying combinations after 1.5 seconds, usually catastrophic backtracking caused by nested or overlapping repeats. Make the pattern more specific, for example anchor it or replace (a+)+ with a+.

Built By Engineers

Need Something Built For Your Business?

aimEncoders designs and builds custom software, websites and internal tools, backed by automated QA.

  • Reply within 1 business day
  • Fixed quote, no surprise invoices
  • You own 100% of the code

Free discovery call • Straight to a developer • Strict NDA available

Regex Tester – Test JavaScript Regular Expressions Online | aimEncoders