Key takeaways
- Enter the pattern body without slash delimiters and choose flags separately.
- A disposable worker stops matching after about 500 milliseconds.
- Replacement strings can refer to numbered and named capture groups.
The regex tester runs JavaScript regular expressions against text you provide, highlights matches and lists captures. A replacement field lets you inspect a transformed version without overwriting the input. Use it for small representative samples before applying a pattern in the application where it will eventually run.
Every matching job runs in a disposable Web Worker. If it does not finish within about 500 milliseconds, the tool terminates the worker and reports a timeout. Editing the pattern, flags, input or replacement cancels the previous job. The result area waits for the current job, so an older result is not presented as the answer to newer text.
Know the engine and input format
This is the browser’s JavaScript RegExp engine. Syntax and behavior are defined by the ECMAScript RegExp specification, checked 16 November 2026. A pattern intended for another language or regex engine needs testing there too. This interface supports the flags g, i, m, s, u and y rather than every possible engine option.
Enter only the pattern body. For example, type cat, then select i if matching should ignore case. Do not paste /cat/i into Pattern: the slashes and letter would become part of the body rather than selecting a flag. Backslashes are entered directly into the field, without a JavaScript string literal’s extra escaping layer.
The sample is small enough to inspect manually. Replace it with representative valid and invalid cases for your own task. Include text that nearly matches as well as text that matches completely. A successful result on a single friendly example is not evidence that an expression behaves well for every possible input.
Step by step with CrizaTools
- Enter Pattern (without / delimiters). Invalid syntax produces an error associated with that field after the worker responds.
- Select the required Flags. Use g for repeated matching and i for case-insensitive matching when appropriate.
- Paste the sample into Test text. Matching updates after a short typing pause.
- Enter Replacement if you want a transformed preview. Use
$1,$2or$<name>to insert captures,$&for the complete match and$$for a literal dollar sign. - Read the status count and Highlighted matches, then inspect each row of the capture table. Indexes are zero-based positions in the JavaScript string.
- Inspect Replace preview and use Copy replacement only after verifying the result. The preview does not modify Test text.
- If the worker times out, shorten the input or simplify the pattern. A timeout leaves no completed match result to interpret.
The highlighting uses text nodes rather than interpreting the sample as HTML. Empty matches display a vertical marker, ¦, because they have no visible matched characters. That marker is a display aid and is not inserted into the original string or replacement preview.
Worked example: two captures and a replacement
Enter pattern (\w+)=(\d+), enable g and use tea=12 milk=3 as Test text. Enter $1:$2 as Replacement. There are two matches: tea=12 at index 0 and milk=3 at index 7. Group 1 contains the name, and group 2 contains the digits.
The preview is tea:12 milk:3. Uncheck g and repeat: only the first match is returned and replaced, so the second assignment remains unchanged in the preview. The two-match count, indexes and complete replacement are verified in Node tests using the same matching logic as the worker.
To name the first capture, change the pattern to (?<name>\w+)=(\d+). The capture table now includes the name entry as well as the numbered groups. Replacement $<name>:$2 gives the same text in this example. Group names can make a replacement easier to review when the pattern contains several captures.
Worked example: empty matches and sticky matching
Enter pattern (?:), enable g and u, and use a single emoji 😀 as Test text. The pattern matches an empty position before and after the character. The tool reports two matches, at UTF-16 indexes 0 and 2, and Replacement - gives -😀-.
With u enabled, advancing after an empty match respects the supplementary character rather than stopping between its two code units. This case is checked in the matching tests. The visible markers indicate positions; they do not mean the expression matched the emoji itself.
For a sticky variation, use pattern a, text ba and only y. There is no match because the worker starts the regex cursor at zero and sticky matching requires a match there. Compare with g without y, which can search forward. This helps distinguish a flag choice from an error in the pattern body.
Limits and timeout behavior
Patterns are limited to 1,000 characters, test text to 20,000 and replacements to 2,000. The tool displays at most 1,000 matches; a larger result produces an error asking for a narrower pattern or shorter input. Replacement output is capped at one million characters, with a conservative expansion check before building it.
The worker budget covers its startup, matching and replacement work. On a busy device, a job may exceed the budget even when it would finish elsewhere. The timeout message means the operation was stopped, not that the input failed to match. There is no automatic retry with a longer unrestricted run on the main page.
Patterns with nested or overlapping repetition can take unexpectedly long on near-matching text. For example, an ambiguous repeated expression can spend time exploring alternatives before rejecting a suffix. Prefer a clearer pattern and smaller sample rather than repeatedly raising input size. The worker boundary keeps that experiment away from the page’s main interaction thread.
Common mistakes
Do not assume match indexes count visible characters: JavaScript positions use UTF-16 code units. Do not confuse m, which changes anchor behavior, with s, which changes whether dot can include line terminators. Test those flags separately against a short multiline example so their effects are visible.
Another common mistake is checking replacement output while forgetting g is off. The first match can look correct while later occurrences remain untouched. Also check unmatched optional groups, literal dollar signs and punctuation around captures. The tool does not prove that an expression is suitable for validation, production input limits or another engine.
Questions and answers
Why is my pattern containing slash delimiters not working?
The field expects the pattern body only. Remove the outer slashes and choose flags with the checkboxes below it.
Why did matching time out?
The disposable worker exceeded its roughly 500 ms budget. Simplify the pattern or reduce the sample; the timeout is not a no-match result.
How are named captures shown?
The capture table includes the named group entry alongside numbered captures. Refer to it in Replacement using $<name>.
Why is a vertical bar highlighted with no text?
The marker represents an empty match position. The original string and replacement output do not acquire that display marker.
Does this send the test text anywhere?
No. Matching and replacement run in the browser worker. The tool does not upload the sample or place its contents in URLs.
Test a sample with the regex tester and inspect longer wording changes using the text difference checker.
Free tools for this
PDF & image
Regex Tester
Test JavaScript regular expressions with flags, live match highlighting, capture groups and replacement preview.
PDF & image
Text Difference Checker
Compare two texts by line or word, see added and removed counts, and switch between inline and side-by-side views.
PDF & image
JSON Formatter
Format, validate and minify JSON in your browser. Shows the line and column of any error, sorts keys and copies or downloads the result.