{{ summaryTitle }}
{{ primaryMetric }}
{{ summaryLine }}
{{ statusBadge }} {{ normalizedFlagLabel }} {{ sampleSizeLabel }} {{ result.warnings.length }} note(s)
Pattern Sample {{ regexPrefieldStage.flagLabel }} Flags
Regex Tester inputs
Enter one JavaScript regex pattern without leading and trailing slash characters.
Toggle the flags used to compile the expression; global mode lists every non-overlapping match.
Paste text, browse a TXT/log file, or drop a text file directly on the textarea.
{{ sourceStatus }}
{{ sourceError }}
Optional replacement preview using the same compiled expression.
The sample is still tested; listing and exports stop at this cap.
matches
Increase only for trusted patterns and controlled sample text.
ms
Keeps the browser responsive when a large file is pasted or loaded.
chars
MetricValueCopy
{{ row.metric }} {{ row.value }}
#MatchIndexLine:ColCopy
No matches for the current pattern and sample.
{{ row.number }} {{ row.match }} {{ row.index }}-{{ row.end }} {{ row.line }}:{{ row.column }}
MatchGroupNameValueCopy
No capturing groups participated in the current match set.
{{ row.matchNumber }} {{ row.group }} {{ row.name }} {{ row.value }}
{{ replacementText }}

        
Customize
Advanced
:

Introduction:

Regular expressions sit between plain text search and full parsing. A regex describes a text shape with compact syntax, then asks an engine to find spans that fit that shape. That can mean dates in log lines, product codes in spreadsheet exports, name-like words in prose, or tokens that need to be replaced before text is shared.

The same pattern can be useful or misleading depending on the sample being tested. A short sample proves a small idea, but it often misses line endings, repeated records, unusual characters, empty fields, and long runs of nearly matching text. Realistic samples matter because regex behavior is shaped by both the pattern and the input.

Regex syntax is dense because one character can change the search. A dot, caret, dollar sign, bracket, parenthesis, or question mark may be literal in one place and special in another. Captures can record subparts of a match, flags can change the meaning of anchors and repeated scans, and replacement strings have their own token rules. Reading the match span alone is rarely enough when the regex will be reused.

Pattern
The rule text, such as a character class, boundary, group, quantifier, or alternation.
Flag
An option that changes how matching works, such as case-insensitive search or repeated matching.
Match
A span of sample text that satisfies the pattern.
Capture group
A parenthesized subpart of a match that can be inspected or reused in replacement text.
Regex pattern, flags, and sample text flow into matched spans, capture groups, replacement text, and guardrail notes
Regex evidence comes from the pattern, flags, sample text, and limits used for that run.

Flags are not decoration. A pattern with g can list repeated non-overlapping matches, while the same pattern without g usually stops at the first match. The m flag changes line anchors, s changes dot behavior, and Unicode-aware modes can change which syntax is valid. A result copied from another language can fail in JavaScript because regex dialects are related, not identical.

Replacement is a second operation, not a guaranteed consequence of a successful match. Numbered captures, named captures, the full match token, and literal dollar signs have special meanings, so correct matched spans can still produce wrong rewritten text. This is most visible when a cleanup pattern is tested on a tiny sample and then applied to a longer file.

Regexes can also be slow. Nested repetition and overlapping alternatives can trigger excessive backtracking on difficult input, especially when the expression is reused in a user-facing validation path. A timeout warning is a useful signal, but it is not a proof of safety across every runtime, input length, or production workload.

How to Use This Tool:

Start with the smallest realistic sample that proves the rule, then widen the sample only after the summary and result tabs agree.

  1. Enter the JavaScript regex in Pattern without slash delimiters. If the summary changes to Regex needs review, fix the compile error before reading any match output.
  2. Choose the needed Flags. Use g when every non-overlapping match should appear, d when capture start and end positions matter, and keep u and v separate because the flag controls reject that combination.
  3. Paste text into Sample text, drag a text-like file onto the area, or use Browse TXT. A file over 4 MB is rejected before it is read, and the source status shows the current character count.
  4. Use Load sample to restore the built-in example or Reset sample to clear the sample. Keep at least one positive case and one negative case in the sample when the regex will later validate real input.
  5. Add Replacement only when you need a rewrite preview. The preview follows JavaScript replacement tokens such as $&, $1, $<name>, and $$.
  6. Open Advanced when the default guardrails are too tight or too loose. Match cap can be 1 to 2,000, Execution timeout can be 50 to 5,000 ms, and Sample limit can be 1,000 to 500,000 characters.
  7. Read Match Preview first for a visual scan, then confirm exact positions in Match Ledger, capture participation in Capture Groups, rewritten output in Replacement Text, and truncation or cap evidence in Run Metrics.

Interpreting Results:

Trust the match count only after checking the warnings. A matched status means the expression found at least one span in the tested sample, not that the pattern is a complete validator or a safe production regex. Use Run Metrics to confirm how much text was searched and whether any guardrail changed the evidence.

Regex tester result cues and corrective checks
Result cue What it means What to verify
matched At least one span in the tested sample satisfies the pattern. Open Match Ledger and confirm the matched text, index range, line, and column.
no match The regex compiled but found no span in the tested sample. Check case sensitivity, anchors, line endings, sample truncation, and whether g or y is needed.
invalid The pattern, flags, or timed run failed before a trustworthy match set was produced. Resolve the summary error first, especially unsupported flags, the u plus v conflict, or a timeout.
Capture rows Each participating group is listed with its group number, optional name, and value. Enable d when capture start and end positions are needed, then compare capture values with Match Preview.
Replacement changed text The replacement preview differs from the tested sample. Review Replacement Text for misplaced capture references, literal dollar signs, or overbroad matches.
Warning badge A cap, truncation, first-match-only run, missing capture indices, timeout, or zero-width match note affected the run. Fix the warning condition before comparing two pattern revisions or copying the result into another workflow.

For fair comparisons, keep the same pattern, flags, sample text, match cap, timeout, and sample limit across revisions. A changed count can come from different guardrails rather than a better expression.

Technical Details:

JavaScript regular expressions are compiled from a pattern string and a flag string. The pattern supplies the matching grammar, while flags change search repetition, case handling, line-anchor behavior, dot behavior, Unicode mode, sticky matching, and index reporting. Syntax support follows the current browser runtime, so a pattern copied from another regex engine may need adjustment.

Repeated matching depends on mutable scan position. With g or y, each successful match advances the scan, and a zero-width match must advance at least one code unit to avoid repeating forever at the same position. Without g or y, JavaScript returns a first match for the search rather than an inventory.

Transformation Core:

Regular expression transformation stages
Stage Mechanism Reader impact
Compile The pattern string and normalized flag string are compiled as a JavaScript regular expression. Invalid syntax or unsupported flags stop the run before match evidence is shown.
Limit sample Only the selected number of sample characters is searched when the input is longer than the sample limit. A truncation warning means later text was not tested.
Scan g and y repeat the scan; otherwise the search stops after the first match. Match count is not comparable unless repeated-search behavior is the same.
Record spans Each match stores matched text, start index, end index, line, column, and length. The ledger can be checked against the sample without relying on highlighted text alone.
Record captures Each group is listed as participated or not matched, with an optional group name and index data when available. A group can exist in the pattern but still have no value for a specific match.
Preview replacement The same expression is used to rewrite the tested sample with JavaScript replacement-string semantics. Replacement output must be reviewed separately from match success.

Flag Reference:

Supported JavaScript regular expression flags
Flag Meaning Practical effect
d Indices Adds start and end positions for matches and captures where the browser supports them.
g Global Finds repeated non-overlapping matches rather than stopping after the first one.
i Ignore case Treats letter case differences as non-matching differences only where the runtime defines that behavior.
m Multiline Lets ^ and $ work at line boundaries, not only at the whole-sample boundaries.
s Dot all Lets . match newline characters.
u Unicode Treats the pattern as Unicode-aware and changes which escapes and character handling rules apply.
v Unicode sets Extends Unicode-aware matching with newer set notation and string-property behavior where supported.
y Sticky Matches only at the current scan position instead of searching forward for a later start.

Guardrails and Limits:

Regex tester limits and warning conditions
Limit or rule Minimum Maximum Warning or effect
Match cap 1 2,000 Stops storing match rows once the selected cap is reached.
Execution timeout 50 ms 5,000 ms Stops a run that does not finish inside the selected time.
Sample limit 1,000 chars 500,000 chars Searches only the first selected number of characters and reports truncation.
Loaded file size 0 bytes 4 MB Rejects oversized text files before reading them into the browser view.
u with v n/a n/a Reports a flag error because the two Unicode modes are mutually exclusive.

A concrete run shows why these details matter. Pattern \b(?<word>[A-Z][a-z]+)\b with flags dg over Ada wrote code. Grace reviewed it. records Ada and Grace as two matches, lists each word capture, and can expose capture indices because d is enabled. Removing g keeps the expression valid but returns only the first match, so the match count drops for a reason unrelated to the pattern's character rule.

Regular expression denial of service risk, often shortened to ReDoS, is tied to runtime cost, not just syntax validity. Patterns with nested repetition or overlapping alternatives can be harmless on a friendly sample and slow on a crafted near-miss string. Treat timeout evidence as a prompt to simplify the expression, narrow the accepted input, or retest in the exact runtime where the regex will be used.

Privacy and Accuracy Notes:

The pattern, flags, sample text, replacement value, and loaded text files are evaluated in the browser after the page loads. Copy and download actions use the current browser result; they do not add a separate server-side regex check.

Accuracy is tied to JavaScript RegExp behavior in the current browser. Recheck the regex in the destination language or older runtime before using it in application validation, log processing, build scripts, or security-sensitive filtering.

Worked Examples:

Capitalized name scan

With Pattern set to \b(?<word>[A-Z][a-z]+)\b, Flags set to dg, and sample text Ada wrote code. Grace reviewed it., the summary shows 2 matches. Match Ledger lists Ada and Grace, while Capture Groups records the named word value for each match.

First-match-only surprise

The same sample with flags set to d still compiles, but the summary shows 1 match and a warning that the expression is not global or sticky. Turn on g before treating the match count as a full inventory.

Date replacement check

Pattern \b(\d{4})-(\d{2})-(\d{2})\b, flags g, sample Due 2026-05-31, and replacement $3/$2/$1 produce Due 31/05/2026 in Replacement Text. If the preview also changes text outside the date, the pattern is too broad.

Large log boundary

If a 120,000-character log is tested with Sample limit set to 50,000, Run Metrics reports Sample characters tested as 50,000 of 120,000 and a warning explains the truncation. Raise the limit or paste the relevant slice when matches near the end matter.

Slow near-miss pattern

A pattern such as (a+)+$ may run fast on aaaa but struggle on a long string of a characters followed by !. If Execution timeout stops the run, simplify the nested repetition before using the regex on untrusted input.

Advanced Tips:

  • Use dg while building a pattern when supported. g gives a repeated match inventory, and d adds start and end indices for matches and captures.
  • Keep a negative case in Sample text beside the positive case when the regex will validate input, otherwise a broad pattern can look correct too early.
  • Check Run Metrics before comparing pattern versions. A different Match cap, Execution timeout, or Sample limit can change the evidence without improving the regex.
  • Review Replacement Text after every capture change because $1, $<name>, $&, and $$ follow replacement-string rules, not match-preview rules.
  • Retest JavaScript patterns in the destination runtime when using newer flags such as d or v, or when the regex was copied from another language.
  • Simplify nested quantifiers before raising Execution timeout for untrusted text. A longer timeout can hide slow-pattern risk instead of fixing it.

FAQ:

Should I include slash delimiters?

No. Enter only the pattern text in Pattern, such as \d{4}-\d{2}-\d{2}, and choose flags with the flag controls.

Why do I see only one match?

JavaScript returns only the first match unless g or y is enabled. Use g when Match Ledger should list every non-overlapping match.

Why are capture positions blank?

Capture values can appear without position data. Enable the d flag when capture start and end indices are needed.

What does a timeout mean?

The run did not finish inside Execution timeout. Reduce the sample, simplify the pattern, or raise the timeout only for trusted patterns and controlled text.

Can I test a whole file?

You can browse, paste, or drop a text-like file under 4 MB. The regex still searches only up to the selected Sample limit, so check Run Metrics for truncation.

Does the sample text leave my browser?

The regex run happens in the browser after the page loads. Treat copied, downloaded, or manually shared results as your responsibility because they can contain the sample text.

Glossary:

Regex
A regular expression, or compact pattern for matching text.
Flag
A JavaScript RegExp option such as g, i, or d that changes matching behavior.
Capture group
A parenthesized part of a pattern that records a submatch for review or replacement.
Named capture
A capture group with a name, referenced in JavaScript syntax with ?<name> and replacement syntax with $<name>.
Zero-width match
A match that succeeds without consuming characters, such as a boundary or anchor.
ReDoS
Regular expression denial of service, where a slow regex can consume excessive runtime on difficult input.

References: