.Any character except newline (with the s flag: including newline).
Regular expression syntax as used by JavaScript, Python (re), PCRE and most editors. Try any pattern in the live regex tester.
27 entries
.Any character except newline (with the s flag: including newline).
\d \w \sDigit, word character [A-Za-z0-9_], whitespace.
\D \W \SNegations of the above.
[abc] [a-z] [^0-9]Character set, range, negated set.
\. \* \\Escape special characters with a backslash.
^ $Start / end of string (of each line with the m flag).
\b \BWord boundary / not a word boundary.
* + ?0 or more, 1 or more, 0 or 1.
{3} {2,} {2,5}Exactly 3, 2 or more, between 2 and 5.
*? +? {2,5}?Lazy versions: match as little as possible.
(abc)Capturing group, available as $1 / \1.
(?:abc)Non-capturing group.
(?<year>\d{4})Named group (JS, Python uses (?P<year>…)).
cat|dogAlternation: either side.
(\w)\1Backreference: repeated character, e.g. "ll".
\d+(?=px)Lookahead: digits followed by px.
\d+(?!px)Negative lookahead.
(?<=\$)\d+Lookbehind: digits preceded by $.
(?<!-)\b\d+Negative lookbehind.
g i m s u yGlobal, case-insensitive, multiline, dotAll, unicode, sticky (JavaScript).
re.I re.M re.S re.XPython equivalents; re.X allows comments and whitespace.
^[^\s@]+@[^\s@]+\.[^\s@]+$Pragmatic email check (real validation = send an email).
https?:\/\/[^\s/$.?#].[^\s]*URL in text.
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$ISO date YYYY-MM-DD (does not check month lengths).
^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$Hex colour.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Password: 8+ chars with lower, upper and digit.
^\s+|\s+$Leading or trailing whitespace (use with g to trim).
Greedy quantifiers (*, +) match as much text as possible and then back off; lazy ones (*?, +?) match as little as possible. For "<a><b>", <.*> matches the whole string while <.*?> matches only "<a>".
The core syntax is shared, but details differ: Python writes named groups as (?P<name>…), older JavaScript engines lacked lookbehind, and POSIX tools like grep use a smaller syntax unless you pass -E or -P.
Use the QuickRef.dev regex tester: it highlights matches live, lists capture groups and explains each token of your pattern.