Dot isn’t everything
. skips line breaks unless you add /s, and even then it matches code points—not whole emojis. A single emoji can be two code units wide.
Note: This uses your browser’s ECMAScript regex engine. Some PCRE tokens (e.g., atomic groups) aren’t supported.
A Regular Expression (Regex) is a pattern for matching text. Use them to search, validate, and replace.
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$^\d{4}-\d{2}-\d{2}$. any char · \w/\d/\s word/digit/space · [a-z] ranges
^ start · $ end · \b word boundary
(…) capture · (?:…) non-capture · (?=…)/(?!…) lookahead
*/+/? · {m,n} · +? lazy
. skips line breaks unless you add /s, and even then it matches code points—not whole emojis. A single emoji can be two code units wide.
Patterns like (a+)+b on a thousand as can lock the engine, trying millions of paths. Small tweaks (a+b or lazy quantifiers) avoid it.
The modern d flag returns start/end offsets for each capture. Great for highlighting matches without re-running the pattern.
Alternations run left to right. In /(cat|catalog)/, “cat” wins first, so “catalog” never triggers the second branch.
Regex theory came from neurophysiologist Stephen Kleene in the 1950s. Decades later, grep (1973) brought it to Unix terminals.