This tool counts how many times a word, phrase, or pattern appears in a block of text. It is useful for checking keyword density in an article, auditing how often a term repeats in a document, tallying specific entries in a log, or verifying that a find-and-replace covered every occurrence. The count updates live as you type, with three matching modes: substring, whole-word, and regular expression.
How it works
The tool builds a global regular expression from your search term. For a literal search, any special regex characters in your input are escaped so the term is matched exactly as typed. Switching on regex uses your input as a pattern directly — without escaping. Whole-word mode wraps the term in \b word boundaries, excluding matches that occur inside longer words. Case-insensitive mode adds the i flag. The tool then counts non-overlapping matches left-to-right across your text.
Worked example
In the text “the cat sat on the mat with the hat”:
| Search | Mode | Count | Why |
|---|---|---|---|
the | substring | 3 | Matches “the” in three positions |
at | substring | 4 | Matches inside “cat”, “sat”, “mat”, “hat” |
at | whole word | 0 | ”at” never appears as a standalone word |
the | whole word | 3 | ”the” is always a standalone word here |
[cm]at | regex | 2 | Matches “cat” and “mat” |
Using regex for power counting
The regex mode opens up patterns that literal search cannot handle:
- Count sentences ending with a question mark:
\?(or\?\sfor more precision). - Count any word starting with a capital letter:
\b[A-Z][a-z]+. - Count lines that start with a number:
^\d(with themmultiline flag built in). - Count email addresses:
\b[\w.-]+@[\w.-]+\.\w{2,}\b.
If your regex is invalid, the tool catches the error and shows a message rather than crashing.
Common uses
- Keyword density check: paste an article and count how many times your target keyword appears before publishing.
- Log triage: paste a server log and count occurrences of
ERRORor a specific status code. - Writing audit: check how often you have used a word like “very” or “thing” before editing.
- Find-and-replace verification: after a global replace, confirm zero occurrences of the old term remain.
Everything runs in your browser — nothing you paste is uploaded.