Regex Match Counter & Frequency Analyzer
Count total and unique regular expression matches, measure execution latency in milliseconds, rank top match frequencies, and inspect color-coded inline highlights.
Inline Highlighted Preview
Color-coded by frequency rankMatch Frequency Table
How Regex Match Counting, Flags & Frequency Analysis Work
Standard regex testers highlight whether a pattern matches, but during incident response, log triage, and data cleaning, engineers usually need quantitative aggregation: how many total matches occurred, how many distinct values appeared, and which IP addresses, HTTP status codes, or email domains dominate the log extract. The Regex Match Counter & Frequency Analyzer combines live inline highlighting with an automatic frequency distribution table.
Under the hood, the analyzer compiles your expression using the browser's native ECMAScript RegExp engine with configurable flags: g (global), i (case-insensitive), m (multiline), s (dotAll), and u (Unicode). Execution duration is measured with high-resolution performance.now() timing so you can spot expensive backtracking patterns immediately.
To prevent browser freezes on edge-case expressions that match zero-length positions (such as ^, $, or optional quantifiers like a*), the iteration loop explicitly advances regex.lastIndex whenever match[0].length === 0 and caps runaway match collections safely. Every matched unique value is ranked in descending frequency order and can be exported as CSV with one click.
Match Share & Zero-Length Safe Iteration
Every match span is aggregated into a hash map keyed by matched text, sorted by descending count, and expressed as a percentage share of total matches.
Unique Match Share % = (Count(value) / TotalMatches) * 100
Execution Latency = performance.now()_end - performance.now()_start
// Zero-length match safeguard during global exec():
if (match[0].length === 0) regex.lastIndex += 1; Code Equivalents (Python & JavaScript / Node.js)
import re
from collections import Counter
logs = """
2026-11-22T20:01:02Z INFO 10.0.14.22
2026-11-22T20:01:03Z WARN 192.168.1.45
2026-11-22T20:01:04Z INFO 10.0.14.22
"""
pattern = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
matches = pattern.findall(logs)
freq = Counter(matches).most_common()
print(f"Total: {len(matches)}, Unique: {len(freq)}")
for value, count in freq:
print(f"{value}: {count}") const text = '10.0.14.22 OK\n192.168.1.45 429\n10.0.14.22 OK';
const regex = /\b(?:\d{1,3}\.){3}\d{1,3}\b/g;
const t0 = performance.now();
const counts = new Map();
let total = 0;
for (const match of text.matchAll(regex)) {
total++;
counts.set(match[0], (counts.get(match[0]) ?? 0) + 1);
}
const elapsedMs = performance.now() - t0;
const ranked = [...counts.entries()].sort((a, b) => b[1] - a[1]);
console.log({ total, unique: ranked.length, elapsedMs, ranked }); Frequently Asked Questions
Why does the match counter only find 1 match when the "g" flag is off? +
In JavaScript, omitting the global (g) flag instructs RegExp.exec() to stop after finding the first match. Enable the "g" flag to scan the entire test string and build a full frequency table.
How does the tool prevent infinite loops on zero-length regex matches? +
Patterns like ^, \b, or a* can match empty strings without advancing the cursor. Our matcher detects zero-length matches and increments regex.lastIndex by 1 while enforcing a 10,000-match safety ceiling.
What is catastrophic backtracking (ReDoS)? +
Nested ambiguous quantifiers such as (a+)+$ can cause exponential evaluation time on non-matching strings. Watch the Execution Time (ms) metric and prefer atomic/non-overlapping character classes.
Can I paste sensitive production logs here safely? +
Yes. All regex evaluation, frequency counting, and CSV generation run strictly inside your local browser tab with zero server requests.