Developer

Regex Tester & Extractor

Test regex patterns in real time, highlight matches, inspect capture groups, and generate code snippets.

Regex Workspace
Matches: 2
HIGHLIGHT RESULT
product-120
order-42
invalid
CAPTURE GROUPS
#Full MatchGroups
1product-120g1: product | g2: 120
2order-42g1: order | g2: 42
Reference

Regex Cheat Sheet

TokenMeaning
.Any character except newline
\dDigit (0-9)
\wWord character
\sWhitespace
^ / $Start / end of line
[abc]Any character in class
[^abc]Any character not in class
( ... )Capture group
(?: ... )Non-capturing group
a|bAlternation
* + ?Quantifiers
{n,m}Range quantifier

Code Snippet

const regex = new RegExp('(\\w+)-(\\d+)', 'g');
const text = 'product-120
order-42
invalid';
const matches = [...text.matchAll(regex.global ? regex : new RegExp(regex.source, regex.flags + 'g'))];
console.log(matches);
A text card with a few highlighted segments under a magnifying glass, with an asterisk and bracket symbols beside it

How to use

  1. Type your pattern in REGEX PATTERN, for example (\w+)-(\d+), and set the FLAGS such as g, i or m.
  2. Paste the text to search into SAMPLE TEXT. Every match is highlighted in HIGHLIGHT RESULT as you type, and the match count updates.
  3. Open CAPTURE GROUPS to see the full match and each group, which is what you would read in code.
  4. Pick a LANGUAGE and click COPY SNIPPET to get ready-to-run code in JavaScript, TypeScript, Python, PHP, C# or Go.

Test a regular expression in real time

A regex tester shows exactly what a pattern matches before you put it in code, which saves the guess-run-fix loop. Matches update as you type, a syntax error is reported right away, and the capture groups show what each pair of parentheses picked up.

The tester uses the JavaScript regular expression engine built into your browser, the same one Node.js and front-end code use. Most everyday patterns work the same in Python, PHP, C# and Go, but some features differ between engines, so run the generated snippet in your language once.

Flags

Flags change how the whole pattern behaves:

FlagNameEffect
gglobalFind all matches, not only the first
iignore caseTreat upper and lower case as the same
mmultilineMake ^ and $ match at the start and end of each line
sdotAllLet . also match line breaks
uunicodeTreat the pattern and text as Unicode code points
ystickyMatch only at the current position
dindicesRecord where each capture group starts and ends

Patterns people look up most

Some starting points you can paste and adapt: digits only ^\d+$; a simple email check [^\s@]+@[^\s@]+\.[^\s@]+; a US ZIP code ^\d{5}(-\d{4})?$; a date like 2026-10-24 (\d{4})-(\d{2})-(\d{2}); and repeated spaces \s{2,}. Test each against both text that should match and text that should not.

Be careful with patterns that nest repetition, such as (a+)+, on long input: they can take a very long time in many engines. Prefer specific character classes over .* when you can, and add ^ and $ when the whole string must match.

Frequently asked questions

Which regex flavor does this tester use?

JavaScript (ECMAScript), as built into your browser. Patterns that use features specific to PCRE, Python or .NET may need small changes; the code snippet helps you check in your language.

Why does my pattern only find one match?

Without the g (global) flag, a JavaScript regex stops after the first match. The tester lists all matches, but add g in your code if you want every one.

How do I match a literal dot or bracket?

Escape it with a backslash: \. matches a dot, \( a parenthesis and \[ a bracket. Without the backslash, these characters have a special meaning.

Is my text uploaded?

No. Matching runs in your browser, so you can safely test patterns on logs or data you cannot share.

Found a problem or have an idea? Report a problem

Share

You might also like