Count occurrences by searching for a literal string; for “aa” in “aaaa,” non-overlapping mode finds 2 matches and overlapping mode finds 3.
Both totals are correct because they answer different questions. The non-overlapping result counts separate matches, while the overlapping result counts every valid starting position, including starts that share characters. This makes the overlap setting as important as the search text itself.

What the example measures
Count Occurrences searches pasted text for one specified string. It is a literal substring counter, not a word counter, list-frequency analyzer, or regular-expression engine. A match can sit inside a longer word, and the tool has no whole-word boundary mode. It is suitable when you need to locate a specific token, separator, log marker, code fragment, ID, punctuation mark, or exact phrase.
In the sample, non-overlapping mode identifies a match starting at position 0, advances past both matched characters, and finds another at position 2. Overlapping mode advances only one string unit after each match, so it also finds starts at positions 1 and 2. Those position lists explain why the totals differ.
The tool reports offsets against the original source, even when it uses a lowercase comparison copy for case-insensitive searching. It does not trim the source, collapse whitespace, or rewrite the text before counting.
Run a literal occurrence count
- Paste or type the source text. Add the text you want to search, up to the supported limit of 1,000,000 characters. Preserve any spaces, tabs, line breaks, punctuation, emoji, or other characters that are part of the text you want to match.
- Enter the literal text to find. In Count Occurrences, enter a non-empty search string of up to 1,000 characters. Choose case-sensitive or case-insensitive matching, then select non-overlapping or overlapping behavior. Punctuation is treated literally, so periods, brackets, and asterisks do not need to be escaped.
- Count the matches. Run the count to obtain the total number of matches. The total is not truncated, even when the position preview cannot display every match.
- Review the starting positions. Inspect the first 100 zero-based offsets to see exactly where matches begin. A result of zero is valid and displays no positions rather than indicating that the search failed.
Choose how overlapping matches are counted
The explicit overlap control lets you choose between two common interpretations instead of having the tool switch behavior based on the input.
| Mode | Where scanning continues after a match | What the total represents |
|---|---|---|
| Non-overlapping | Past the entire matched search string | Separate matches that do not reuse matched characters |
| Overlapping | One JavaScript string unit | Every valid starting position, including matches that share characters |
Use non-overlapping mode when you want the number of separate literal matches or the number of replacements a straightforward literal replacement would make. Use overlapping mode for sequence analysis, where a valid match can begin inside the preceding match.
The distinction also matters for repeated fragments and punctuation runs. Choosing a mode based on the result you need prevents a technically correct count from being interpreted incorrectly.
Set case and literal-match rules
Case-sensitive mode compares the source and search strings exactly. Case-insensitive mode converts both inputs using English-locale lowercase behavior for the comparison. It does not rewrite the source, and the reported positions still refer to the original text.
This case-insensitive behavior is practical rather than a complete linguistic collation system. Locale-specific equivalence, Unicode normalization between composed and decomposed forms, accent folding, and script-specific case rules are not inferred. For example, visually similar but differently encoded characters should not be assumed equivalent unless the selected browser behavior actually compares them that way.
Literal matching also keeps the search predictable. A period matches a period, an asterisk matches an asterisk, and brackets have no special syntax. The search string may contain spaces, tabs, pasted line breaks, emoji, or ordinary Unicode text. A match can span a newline when the search text contains that newline. An empty search is rejected because it would match at every boundary, while a search longer than the remaining source naturally returns zero.
Interpret zero-based positions
The displayed positions are zero-based JavaScript string offsets, so the first string unit has offset 0. Most ordinary English characters consume one offset, while characters represented by surrogate pairs can consume two UTF-16 code units. An emoji can therefore cause later positions to look numerically different from a count based on visible characters.
These offsets are intended for reproducible browser and programming work, not as user-perceived grapheme indexes. They are useful when you need to confirm the exact location of a literal match, but they should not be treated as a count of visible symbols.
The total always includes every match, while the page displays at most 100 starting positions to keep a large result usable. The position preview remains in the page and does not create a download. Editing the source, search text, or matching options clears the previous output so an old count cannot be mistaken for the current result.
Match the mode to the task
Choose the setting that reflects the question you are trying to answer:
- Repeated markers or IDs: Use an exact literal search, usually with case sensitivity when capitalization distinguishes one marker from another.
- Shared sequences: Turn on overlapping detection to include every valid start where a match reuses characters from the preceding match.
- Separate replacements: Use non-overlapping detection, which reflects the number of matches a simple literal replacement would handle.
- Word totals: If the goal is to count words rather than occurrences of a specified string, use Word Counter instead.
- Text changes: If you need to alter the matches, use Find and Replace Text rather than treating counting as an editing step.
- Version comparisons: Use Text Diff Checker when the real task is to compare two bodies of text rather than locate a string in one source.
Check limits before relying on the result
- Input bounds: The source accepts up to 1,000,000 characters, and the search string accepts up to 1,000 characters. These limits protect browser responsiveness.
- Local processing: Matching, counting, and position collection run inside the browser. Neither input is sent to a server, and the operation uses no network or external data.
- No hidden pattern syntax: There is no regular-expression parser, wildcard mode, fuzzy matching, stemming, Unicode normalization, or replacement action. An invalid regular expression cannot break the search because no pattern is compiled.
- No file-upload parser: Paste or type the content directly. The tool does not trim the source, change line endings, collapse whitespace, remove duplicates, or otherwise rewrite the input.
The same browser inputs and options produce the same result, with no randomness or server state involved. For a reproducible record, note the literal search string, case setting, overlap mode, total, and reported offsets.
For a deeper look, see Find and Replace Online Example: Literal Text Changes.
For a deeper look, see Count Occurrences Explained: Exact Matches and Positions.