Text Counter
Count characters, lines, words, and bytes in real time.
Test regular expressions and highlight matches in real time.
A regular expression (regex) is a notation for describing a set of strings using a single pattern. It enables concise expression of complex string searching, replacing, and validation operations. This tool highlights matches in real time as you type the pattern or test text, and lists each matched string along with its position (index) in the text.
m flag to anchor patterns to the start/end of each line and evaluate lines individually.Pattern: [a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,} Flags: gi
Test text:
example@email.com, test.user@domain.jp
Contact us at Contact@Example.com
Because of the i flag, matching is case-insensitive, so all three addresses appear in the results:
#1 example@email.com Index: 0
#2 test.user@domain.jp Index: 19
#3 Contact@Example.com Index: 53
Pattern: \d+ Test text: id: 12, 34, 56
With g included in the flags, all three numbers — 12, 34, 56 — match. Remove g and only the first match, 12, appears in the results. Keep the g flag on whenever you want to search the whole text rather than just the first occurrence.
Pattern: error Test text: ERROR: Connection failed / error: timeout
Without the i flag, only the lowercase error matches. Add i (as in gi) and the uppercase ERROR matches too. This is useful for searching logs where casing isn’t consistent.
Pattern: ^\d+ Flags: gm Test text:
100 apple
200 banana
300 cherry
^ normally matches only the very start of the whole text, but the m (multiline) flag makes it match the start of every line instead, so 100, 200, and 300 all match. Remove the m flag and only the 100 at the very start of the text matches.
JavaScript's built-in regular expression engine. Some syntax may differ from other languages (such as Python's `re` module or PCRE), so double-check against the target language's spec before porting a pattern.
The matched text itself, plus its starting position (index) in the test text. It doesn't currently break results down by capture group (e.g. `match[1]`); use your browser's developer console if you need per-group values.
Without the g (global) flag, only the first match found is shown in the results list and highlighted. Add the g flag if you want to see every occurrence in the text.
Yes. Drop a .txt file (under 5MB) onto the "Test Text" field and its contents are loaded automatically.
An "Invalid regular expression" error is shown along with details of the syntax error, such as an unsupported group construct or a missing closing bracket.
Yes. The pattern is re-evaluated automatically as you type either the pattern or the test text, and matches are highlighted with a background color — no button click required.