What this regex tester does
A regular expression (regex) is a small pattern language for finding text: email addresses in a log, dates in a document, or every word that starts with a capital letter. This tester runs your pattern with the same JavaScript RegExp engine used by web browsers and Node.js, so what works here works in your code. Every match is highlighted in the test text, and the match list shows the matched text, where it starts and ends (zero-based character indices), each numbered capture group, and any named groups such as (?<year>\d{4}). Group positions are shown when your browser supports match indices.
Regex flags explained
- g (global): find all matches. Without it, only the first match is found and replaced.
- i (ignore case):
catalso matches “Cat” and “CAT”. - m (multiline):
^and$match at the start and end of every line, not just the whole text. - s (dotAll): the dot
.also matches line breaks. - u (unicode): treats emoji and other characters outside the basic range as single characters and enables
\p{…}property escapes, such as\p{L}for any letter. - y (sticky): each match must start exactly where the previous one ended, which is useful for tokenizers.
Quick regex cheat sheet
\d digit, \w letter, digit or underscore, \s whitespace, . any character, [abc] one of a, b or c, [^abc] anything else, * zero or more, + one or more, ? optional, {2,4} two to four times, ^ and $ start and end, \b word boundary, (…) capture group, (?:…) non-capturing group, a|b either a or b, and (?=…) lookahead. Add ? after a quantifier, like .*?, to make it lazy so it matches as little as possible.
Safe testing: errors, empty matches and slow patterns
If a pattern is invalid, such as an unclosed bracket, the tester shows the browser’s error message instead of failing silently. Patterns that can match empty text, like a*, are handled by stepping forward one character after each empty match, so the tester never gets stuck. Results are capped at the first 1,000 matches to keep the page fast. Some patterns with nested quantifiers, like (a+)+b, can take an extremely long time on certain text; this is called catastrophic backtracking. The tester runs matching in a background worker and stops it after a short time limit, then tells you the pattern is too slow, which is a sign it needs rewriting before you ship it. Your pattern and text never leave your browser. To tidy JSON you extract, use the JSON formatter, or pull addresses out of text quickly with the email extractor.