What this Regex Tester checks
Regex Tester evaluates a pattern against Test text using JavaScript’s RegExp inside RegexTester.worker.js. The main page does not exec the regex itself; it posts pattern, flags, and testText to a new module Worker on each deferred change. There is no file picker, replace box, code export, or saved-pattern store beyond the in-page PRESETS buttons.
Pattern and test text start empty. The slash decorations around the pattern field are chrome; you type the source string that new RegExp receives, not a literal /pattern/flags token.
Pattern, test text, and flags
- Flags in the UI
- g global, i ignore case, m multiline, s dotall, u unicode. DEFAULT_FLAGS: g true, m true, others false.
- Worker flags
- sanitizeFlags keeps unique characters in the set g,i,m,s,u,y. The UI never sends y (sticky). The d indices flag is not offered.
- Pattern length
- MAX_PATTERN_LENGTH is 1,000. The input does not block typing; the worker returns “Pattern is too long. Use 1,000 characters or fewer.”
- Test text length
- MAX_TEST_TEXT_LENGTH is 20,000. Longer strings are sliced; analysis.truncated shows an amber notice. Matching does not run on the omitted tail.
Empty trimmed pattern skips the worker, resets analysis, and shows “No pattern yet.” Quick examples (Email, URL, Phone number, UUID, Hex color) and Load example (PRESETS[0], Email) fill pattern, flags, and text. Those samples are not RFC or production validators.
How matches and capture groups appear in this tool
collectMatches uses regex.exec. Without g it stores at most one match. With g it loops until exec fails or 500 matches. Zero-length matches increment lastIndex by 1 so the loop can continue. Each listed match shows value, index (string offset from exec, not line/column), and groups from match.slice(1)—numbered capturing groups. Named groups (match.groups) are not labeled by name.
Sidebar Groups is the sum of groups.length on displayed matches, not the number of groups in the pattern. Highlighted preview paints match segments in <mark>; buildHighlightedText forces g if needed. Results header shows totalMatches of the collected list, or Evaluating... while isEvaluating is true.
Invalid patterns, no-match results, and zero-length or repeated matches
- new RegExp throws: worker ok false; UI shows error.message or “Invalid regular expression.” Status Invalid pattern.
- Worker onerror: “The regular expression could not be evaluated.”
- Timeout (300 ms): worker terminated; “Pattern evaluation timed out. Try a simpler expression.”
- Malformed postMessage payload: “Invalid regex evaluation request.”
- No matches after a successful exec loop: “No matches yet. Enter a pattern and test text to inspect results.” (same empty copy as before any run).
- Match cap: later matches after 500 are omitted; there is no separate “truncated matches” flag (truncated is only for test-text length).
How to use the real controls
- Type into Regular expression. The counter line reads Pattern length limit: 1,000 characters. There is no Test button; a useEffect runs after deferred pattern, deferred Test text, and Flags.
- Paste into Test text. If the paste is longer than 20,000 characters, an amber notice reads “Test text was truncated to 20,000 characters for performance.”
- Click Flags buttons as needed: g global, i ignore case, m multiline, s dotall, u unicode. Defaults are g and m on. Toggles re-run the worker immediately.
- Wait if Results shows Evaluating... or Highlighted preview shows Evaluating pattern safely… (that “safely” is UI copy).
- Read Pattern status in Match summary. Valid pattern means the worker built a RegExp without throwing—not that the pattern implements a business rule. Empty pattern shows No pattern yet.
- Click Copy matches to write match values joined by newlines. It omits indexes and group labels. Clipboard failure clears Copied with no red error. The button stays disabled while there are no matches or isEvaluating is true. There is no download and no copy-pattern control.
- Click Load example to apply PRESETS[0] (Email). Click a Quick examples button — Email, URL, Phone number, UUID, or Hex color — for the other samples. Those samples are not RFC or production validators.
- Click Clear to empty Regular expression and Test text and restore DEFAULT_FLAGS. Clear is disabled while both fields are empty.
JavaScript regular expressions versus other regex flavors
This page is the host engine’s JavaScript RegExp, not PCRE, Python, Go RE2, Java, or .NET. A match here does not prove the same source string works in those dialects, in a database constraint, or in a different browser version. Unicode, dotall, and lookaround support follow this constructor, not a portable spec suite.
What this tool does not test or guarantee
- No replace, split, or generated source code.
- No file or directory scanning.
- No saved patterns outside this page load (presets are hardcoded).
- No ReDoS analyzer, complexity score, or performance benchmark beyond killing one worker at 300 ms.
- No proof a pattern is safe for untrusted input or that it validates an application field.
- No line/column map, sticky y control, or named-group labels.
A successful browser-regex test does not prove the pattern works in another language, avoids performance problems elsewhere, or meets a security or business rule.
Privacy and browser-processing boundaries
RegexTester.jsx and RegexTester.worker.js run in the browser. They do not call trackToolEvent and do not POST the pattern or test text to a regex API. That is not a confidentiality guarantee: the rest of the page can still load site assets and advertising; the privacy policy describes first-party analytics for event metadata (not designed to store tool contents); clipboard, extensions, and shared devices remain outside these files.
Do not paste production customer records into Test text. Local RegExp does not encrypt the sample.
A pattern-review checklist
- If g is off, confirm whether you are reading the first-match list or the globally highlighted preview.
- If text was truncated, only the first 20,000 characters were searched.
- If you hit 500 matches, assume more may exist beyond the cap.
- If evaluation timed out, simplify the pattern; do not assume it is safe at runtime in your app.
- Check numbered groups, including those labeled empty; do not assume named-group titles appear.
- Keep the original pattern in your codebase; this page does not download it.
When another DevToolKit tool is more appropriate
- Text Diff Checker — to compare two sample strings line by line. This tester does not diff texts.
- JSON Formatter — when a copied match is JSON and you need JSON.parse pretty-print. This page does not parse JSON.
- URL Encoder/Decoder — when you need percent-encoding (encodeURIComponent / encodeURI), not a URL-shaped regex.