About this tool
This regex tester runs JavaScript regular expressions against your text as you type. Every match is highlighted, and a table lists its position together with the numbered and named capture groups. Below it, a replace preview shows what String.replace returns with $1 or $<name> substitutions, and a split preview shows the pieces that String.split produces.
Developers use it to build and debug patterns for form validation, log parsing, search and replace in editors, and data cleanup. Flag switches, ready-made examples and a cheat sheet also make it a practical way to learn regular expressions. A share link keeps the pattern, flags, test text and replacement.
How it works
Type the pattern without the surrounding slashes and switch flags on or off. g finds every match instead of only the first, i ignores case, m makes ^ and $ match at line breaks, s lets the dot match line breaks, u and v enable full Unicode including \p{…} property escapes, y anchors each match at the current position, and d records where each group starts and ends.
The results are exactly what your browser's engine returns. Without g only the first match is reported, an empty match advances by one character (one code point in Unicode mode), and a group that did not take part in a match is shown as not matched. Replacement strings support $1 to $99, $<name>, $& for the whole match, $` for the text before it, $' for the text after it and $$ for a dollar sign.
Matching runs in a background worker. If a pattern needs more than 1.5 seconds, usually because of catastrophic backtracking, the tool stops it so the page stays responsive.
Example
The default pattern (?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01]) with the g flag finds ISO dates. In the sample invoice text it matches 2026-10-08 and 2026-11-07 but not 2026-13-01, because 13 is not a valid month. For the first match the named groups are year 2026, month 10 and day 08.
The replacement $<month>/$<day>/$<year> turns the dates into 10/08/2026 and 11/07/2026 and leaves the invalid date unchanged. Splitting the same text by the pattern returns nine parts: the text around the two dates plus the year, month and day of each one, because String.split inserts captured groups into its result.
Assumptions and limits
The tester uses the JavaScript engine of your browser, so the results match what the same pattern does in current Chrome, Edge, Firefox, Safari and Node.js. The v flag needs a browser from 2023 or later. The test text is limited to 200,000 characters and the pattern to 5,000; the list stops at 1,000 matches and the table shows the first 200. A pattern that runs longer than 1.5 seconds is stopped. Other regex flavors such as PCRE, Python, Java, .NET and POSIX are not emulated. Your text stays in your browser, but a share link stores it in the URL, so do not share sensitive data that way.
Frequently asked questions
Why does my regex find only one match?
Without the g (global) flag, JavaScript's exec and match return only the first match, and replace changes only the first occurrence. Turn on g to list every match and replace them all. With the y (sticky) flag, each match must also start exactly where the previous one ended.
How do I use capture groups in the replacement?
Put part of the pattern in parentheses and refer to it as $1, $2 and so on, counting opening parentheses from the left. Named groups written as (?<name>…) are referenced as $<name>. Use $& for the whole match and $$ for a literal dollar sign. Groups written as (?:…) do not capture and get no number.
Is a JavaScript regex the same as in Python, PHP or Java?
The basics are shared: character classes, quantifiers, groups, alternation and lookarounds. The details differ. JavaScript has no possessive quantifiers, atomic groups or \A and \Z anchors, Python's re module has no \p{…} property escapes, and PCRE supports recursion. Test a pattern for another language in that language's engine before you rely on it.
What is catastrophic backtracking?
Some patterns, such as (a+)+$ or (.*)*x, can try an exponential number of ways to split the text when a match almost succeeds. A few dozen characters can then take seconds or even hours. The tester runs patterns in a background worker and stops them after 1.5 seconds. To fix the pattern, avoid nested quantifiers over the same characters and make each part match something specific.
Why does \b not work with Cyrillic or accented letters?
In JavaScript, \b and \w only know ASCII letters, digits and the underscore, even with the u flag. For other alphabets use Unicode property escapes with the u or v flag: \p{L}+ matches a word, and the lookbehind (?<!\p{L}) replaces \b at the start of a word, as in the Capitalized words example.
Link with your values
Add these parameters to this page’s address to open it with the values filled in, for example to share a calculation or to link to it from an AI assistant. The result is calculated in the browser: the page HTML shows an example for the default values, and the tool sets the data-url-params attribute once the link’s values are applied.
| Parameter | Value | If omitted |
|---|---|---|
exampleExamples | one of: email, date, hex, words | optional |
patternRegular expression | text in the tool's notation, see the examples; your own text; Copy link includes it | required |
flagsFlags | text in the tool's notation, see the examples | default g |
textTest text | text; your own text; Copy link includes it | optional |
replacementReplacement | text; your own text; Copy link includes it | optional |
Examples
?pattern=(%5Cd%7B4%7D)-(%5Cd%7B2%7D)&text=Due%202026-10%2C%20paid%202027-01&replacement=%242%2F%241?pattern=%5Cbcolou%3Fr%5Cb&flags=gi&text=Colour%20or%20color%3F?example=hex
Write decimals with a point. Encode a space as %20, + as %2B, # as %23 and & as %26.
Result elements: [data-result-block="regex"]