How to test a regular expression
- Enter your pattern between the slashes and set flags by typing them or ticking the boxes.
- Paste sample text into Test text, or click a snippet like Email or IPv4 to start from a pattern.
- Review the highlighted matches and the table of matches, positions and capture groups.
- Optionally type a replacement with $1 or $<name> to preview the replaced text.
What you can do with Regex Tester
- Live highlighting
- Matches are highlighted in alternating colors as you type, so adjacent matches are easy to tell apart.
- Capture group table
- Each match is listed with its index and every numbered and named capture group, for up to the first 500 matches.
- All JavaScript flags
- Toggle g, i, m, s, u and y with checkboxes that stay in sync with the flags field next to the pattern.
- Replacement preview
- Test a replacement string with $1, $& and $<name> references and see the full result immediately.
- Ready-made snippets
- Start from patterns for email, URL, IPv4, phone, hex color, ISO date with named groups, UUID, numbers, hashtags, HTML tags and trailing spaces.
- Clear error messages
- Invalid patterns show the browser's exact syntax error instead of failing silently or matching nothing.
JavaScript regex syntax, flags and flavor differences
Regular expressions describe text patterns with a compact syntax: \d matches a digit, \w a word character, + means one or more, ? makes something optional, and parentheses create capture groups you can reuse in replacements. Flags change the behavior: g finds all matches instead of the first, i ignores case, m makes ^ and $ match at each line, s lets the dot match newlines, u enables full Unicode including \p{L} letter classes, and y anchors matching at the current position.
This tester uses your browser's own JavaScript engine, so results match exactly what your code will do in Chrome, Firefox, Safari or Node.js. Other flavors differ in places: PCRE and Java support features like possessive quantifiers that JavaScript lacks, and Python's re module traditionally writes named groups as (?P<name>) rather than (?<name>). When testing, include text that should not match as well as text that should, and watch for greedy quantifiers like .* consuming more than intended; the lazy .*? is often what you want.
Frequently asked questions
Is the text I test kept private?
Yes. Patterns and test text are evaluated by the JavaScript engine in your browser and never sent to a server. You can safely test against log files, customer data or source code without any of it leaving your device.
Which regex flavor does it use?
It uses JavaScript (ECMAScript) regular expressions as implemented by your browser. That includes lookbehind, named groups and Unicode property escapes. Patterns written for Python, PHP (PCRE) or Java usually work but may need small changes.
How do I see capture groups?
Wrap part of your pattern in parentheses, for example (\d{4})-(\d{2}). The table below the highlighted text adds a column for each group, and named groups written as (?<year>\d{4}) show their name in the column header.
Why does my pattern only find one match?
Without the g (global) flag, JavaScript stops after the first match. Tick g or add it to the flags field to find every match. The y (sticky) flag also changes behavior, because it only matches at the exact current position.
Is there a limit on matches?
The tool counts up to 5,000 matches and lists details for the first 500 in the table, which keeps the page responsive on large inputs. Highlighting still covers every counted match in the text preview above the table.