Regex Tester
Test regular expressions live with highlighted matches and capture groups.
Updated · Examples checked by automated tests
About Regex Tester
Regular expressions are dense, and the fastest way to understand one is to watch it run. This tester compiles your pattern as you type, highlights every match in the sample text and breaks each match into its numbered and named capture groups.
It also includes a replacement preview, so you can confirm that a substitution using $1 style references produces exactly the output you expect before you paste it into your code.
How Regex Tester works in your browser
Patterns are compiled with the browser’s native RegExp and run against your test text with the flags you select. This matters more than it sounds: JavaScript’s regular expression dialect is not PCRE, and a pattern copied from a PHP, Python or Perl example may behave differently or fail to compile. Testing here tells you how the pattern will behave in JavaScript specifically, because it is literally the same engine.
Matches are collected with the global flag and each capture group is listed separately, including named groups from (?<name>...). An invalid pattern surfaces the engine’s own SyntaxError rather than a generic failure.
Regex evaluation runs in a disposable worker with a one-second timeout and a cancel button. The list displays at most 500 matches; that cap alone cannot prevent catastrophic backtracking. Text is limited to 200,000 characters and patterns or replacements to 10,000. Simplify nested quantifiers if execution times out.
When to use it
- Building a validation pattern and seeing which of your real-world sample inputs it rejects.
- Working out why a pattern that behaves correctly in Python does not match in JavaScript.
- Extracting a specific field from log lines by iterating on the pattern against a genuine sample.
- Testing against production log excerpts that should not be pasted into a hosted regex service.
Worked examples
Find every email address in a block of text
Settings: Pattern [\w.+-]+@[\w-]+\.[\w.]+, flags gi
Input
Contact sales@example.com or Support@Example.org.Expected output
Matches: 2
1. sales@example.com
2. Support@Example.org.The global flag finds every match, not just the first. Notice the trailing full stop in the second match: [\w.]+ also accepts dots, so a sentence-ending period is captured. Tighten the pattern to end on a letter, such as \.[a-z]{2,}, when that matters.
Reorder dates with named groups
Settings: Pattern (?<d>\d{2})/(?<m>\d{2})/(?<y>\d{4}), flags g, replacement $<y>-$<m>-$<d>
Input
Invoice 31/12/2025, paid 05/01/2026Expected output
Invoice 2025-12-31, paid 2026-01-05Named groups make the replacement readable: $<y> inserts whatever the y group captured. The pattern does not check that the day or month is valid, so 99/99/2026 would also be rewritten.
Limits and checks before you use the result
- Patterns use JavaScript regular expression syntax. Lookbehind, named groups and the u and s flags work in current browsers, but syntax from PCRE, Python or .NET, such as possessive quantifiers or (?i) inline flags, does not.
- Evaluation stops after one second and lists at most 500 matches, so a runaway pattern cannot freeze the page.
- A pattern that works here can still behave differently in another engine. Test it in the language where it will run.
Frequently asked questions
Why does my regex work elsewhere but not here?
JavaScript regular expressions are not PCRE. Patterns copied from PHP, Python or Perl examples can behave differently or fail to compile. This tester uses the browser engine, so it matches what runs in your code.
Which regex flavour is this?
JavaScript / ECMAScript regular expressions, exactly as they behave in the browser and in Node.js.
Why does my pattern seem to hang?
Certain nested quantifiers cause catastrophic backtracking. The tester terminates its worker after one second and caps displayed matches at 500. Simplify the pattern or shorten the input.
Can I use named capture groups?
Yes. Named groups are supported and are listed by name in the results.
Related tools
Cron Expression Generator
Build and explain cron schedules in plain English.
Base64 Encoder & Decoder
Convert text to Base64 and back, with full Unicode support.
URL Encoder & Decoder
Percent-encode and decode URLs, query strings and components.
HTML Entity Encoder
Escape and unescape HTML entities to display markup safely.
Unix Timestamp Converter
Convert Unix timestamps to human dates and back, in UTC and local time.
Hash Generator
Generate SHA-1, SHA-256, SHA-384 and SHA-512 hashes from text or files.