Regex glossary.

116 regular-expression terms — from anchors and quantifiers to backtracking and Unicode — each defined in plain English with a quick example. Use the search box or jump to a letter.

A

Alternation (|)
The "or" operator in a regex. cat|dog matches "cat" or "dog". Alternation has the lowest precedence of any operator, so ^cat|dog$ means "starts with cat" OR "ends with dog" — wrap it in a group, ^(cat|dog)$, to constrain it.
Alternation precedence
The rule that | binds more loosely than concatenation or quantifiers, so it splits the largest surrounding scope unless parentheses narrow it.
Anchor
A token that matches a position in the text rather than a character. The common anchors are ^ (start), $ (end), and \b (word boundary). Anchors are zero-width — they consume no characters.
Anchor tag
An informal name for the start/end anchors ^ and $ that pin a pattern to the beginning or end of the input.
Anchored match
A match required to begin at a specific position — the start of the string, or (with JavaScript's sticky flag) at lastIndex. Contrast with an unanchored search that scans forward for the first match.
Assertion
A construct that tests whether a condition holds at the current position without consuming characters. Anchors and lookarounds are both assertions; they succeed or fail based on what surrounds the position.
Assertion failure
The outcome when a zero-width test (anchor or lookaround) does not hold at the current position, causing the engine to backtrack or abandon that path.
Astral character
A Unicode character beyond the Basic Multilingual Plane (code point above U+FFFF), such as many emoji. Matching these correctly in JavaScript requires the u flag so they are treated as single code points. Source: The Unicode Standard
Atomic group
A group written (?>...) that, once matched, will not give back (backtrack into) its characters. Atomic groups are a key tool for preventing catastrophic backtracking. Not supported in JavaScript. Source: PCRE2 — syntax

B

Backreference
A reference to text a capturing group already matched, written \1, \2, etc. (\w+)\s+\1 matches a doubled word because \1 must equal whatever group 1 captured.
Backslash (\\)
The escape character in regex. It turns a metacharacter into a literal (\. matches a dot) and turns some letters into special tokens (\d, \b). A literal backslash is written \\.
Backtracking
The engine's process of retrying alternative ways to match after a path fails — undoing a greedy quantifier or trying the next alternation branch. Excessive backtracking is the root of most regex performance problems.
Balancing group
A .NET-specific construct, (?<name-prev>...), that pushes and pops a capture stack to match balanced, nested structures like parentheses — .NET's answer to recursion. Source: Microsoft .NET — regular expressions
Boundary
A position between two characters that a boundary assertion like \b can match. A word boundary sits between a word character (\w) and a non-word character.
Boundary assertion
Any zero-width test tied to a position boundary — \b, \B, ^, $, \A, \z, \G. They match "between" characters rather than characters themselves.
Bounded quantifier ({n,m})
A quantifier specifying a repetition count: {3} (exactly 3), {2,5} (2 to 5), {2,} (2 or more). Also called an interval or bracketed quantifier.
Bracket expression
The POSIX name for a character class — the [...] construct, including ranges and POSIX classes like [[:digit:]].

C

Capture index
The number assigned to a capturing group, counted by the position of its opening parenthesis from left to right, starting at 1 (group 0 being the whole match).
Capturing group
Parentheses ( ... ) that both group a subpattern and save the matched text into a numbered slot for later use in backreferences or replacements. See also non-capturing group.
Caret (^)
Outside a character class, ^ anchors to the start of the string (or the start of each line with the multiline flag). As the first character inside a class, [^...], it negates the class.
Case folding
The engine's normalization of letter case so a case-insensitive match treats "A" and "a" as equal. Unicode case folding also handles pairs like "ß"/"ss" in some engines. Source: The Unicode Standard
Case-insensitive flag (i)
A flag that makes letters match regardless of case, so /hello/i matches "HELLO". Enable it inline with (?i) in most flavors.
Catastrophic backtracking
A pathological slowdown where nested or overlapping quantifiers (like (a+)+$) force the engine to explore exponentially many match paths on a failing input. The mechanism behind most ReDoS vulnerabilities. Source: OWASP — ReDoS
Character class ([ ])
A set of characters in square brackets, any one of which matches at a position. [aeiou] matches one vowel; ranges like [a-z] and shorthands like [\d\s] are allowed inside.
Character range
A span of characters inside a class written with a hyphen, such as [a-z] or [0-9]. The endpoints are compared by code point, so order matters — [z-a] is an error.
Code point
A single Unicode scalar value, the unit that \u escapes and Unicode-aware matching operate on. With the u flag, a regex matches whole code points rather than UTF-16 code units. Source: The Unicode Standard
Comment group
An inert group (?#...) whose contents are ignored by the engine, used to annotate a pattern in flavors that support it.
Compiled pattern
A regex that the engine has parsed and turned into an internal matching program. Reusing a compiled pattern (e.g. re.compile in Python) avoids recompiling it on every call.
Conditional pattern
A construct that matches one subpattern or another depending on whether a group participated, written (?(1)yes|no). Supported in PCRE, Python (3.11+), and .NET, but not JavaScript. Source: PCRE2 — pattern reference
Control character escape (\cX)
An escape for ASCII control characters, where \cA is Ctrl-A (0x01), \cM is carriage return, and so on. Rarely needed outside low-level text protocols.
Control verb
A PCRE backtracking-control construct such as (*SKIP), (*PRUNE), (*FAIL), or (*ATOMIC) that gives fine-grained control over how the engine backtracks. Source: PCRE2 — pattern reference

D

Delimiter
The characters that mark where a pattern begins and ends in languages that use them, usually forward slashes — /pattern/flags in JavaScript, or preg_match('/.../', ...) in PHP.
Deterministic finite automaton (DFA)
An engine model that tracks all possible matches simultaneously in linear time and never backtracks, at the cost of not supporting backreferences or lookaround. RE2 and most POSIX tools use a DFA-style approach.
Digit shorthand (\d)
Matches a single digit. In ASCII mode that is [0-9]; with Unicode enabled it can also match digits from other scripts. Its negation \D matches any non-digit.
Dollar sign ($)
Anchors a match to the end of the string, or (with the multiline flag) the end of each line. In some flavors $ also matches just before a trailing newline; use \z for a strict end-of-string.
Dot / wildcard (.)
Matches any single character except a line terminator by default. Escape it as \. to match a literal period, or enable the dotAll flag to make it match newlines too.
Dot-matches-newline
The behavior enabled by the dotAll (s) flag, in which . also matches line terminators. Off by default in nearly every flavor.
DotAll flag (s)
A flag (also called single-line mode) that lets the dot . match newline characters, so . matches truly any character. Enable it inline with (?s).

E

Empty match
A match of zero length, produced by patterns like a* or a lone lookahead. Engines advance past a zero-length match to avoid looping forever when matching globally.
End-of-string anchor (\z)
A strict end-of-input assertion. Unlike $ or \Z, \z matches only at the very end and never before a trailing newline. Available in Python, Ruby, PCRE, and Java.
Escape sequence
A backslash followed by a character that has special meaning, such as \n (newline), \t (tab), \d (digit), or \. (literal dot).
Escaping
Placing a backslash before a metacharacter so it is treated literally. Escaping ., *, ( and friends is how you match those symbols as ordinary text.
Extended mode (x)
A flag (also called verbose or comment mode) that makes the engine ignore unescaped whitespace and treat # as a line comment inside the pattern, so complex regexes can be laid out and annotated across multiple lines.

F

Finite automaton
The abstract "machine" a regex is compiled into for matching. The two families are the NFA (backtracking, feature-rich) and the DFA (linear-time, restricted).
Flag / modifier
A setting that changes how a pattern matches — case-insensitivity (i), global (g), multiline (m), dotAll (s), Unicode (u), sticky (y), and extended (x) are the common ones.
Flavor
A specific regex dialect with its own syntax and feature set — JavaScript, PCRE, Python re, Java, .NET, Go (RE2), and Ruby (Onigmo) all differ in lookbehind, named-group syntax, and Unicode handling. See our flavor converter.

G

Global flag (g)
A flag that makes a pattern find every match rather than stopping at the first, so str.match(/\d+/g) returns all numbers and replace substitutes every occurrence.
Global match
Finding all non-overlapping matches in the input, driven by the global flag or an "find all"/iterator API such as re.findall or matchAll.
Grapheme cluster
A "user-perceived character" that may consist of several code points, such as an emoji with a skin-tone modifier. Standard regex operates on code points, so matching whole graphemes usually needs a dedicated construct like \X in PCRE. Source: Unicode UAX #29 — Text Segmentation
Greediness
The property of a quantifier that determines how much it matches before backtracking — greedy (maximum), lazy (minimum), or possessive (maximum, no give-back).
Greedy quantifier
A quantifier that matches as many repetitions as possible, then backtracks if needed. *, +, ?, and {n,m} are greedy by default — <.*> grabs everything between the first "<" and the last ">".
Group
Parentheses that bundle part of a pattern so a quantifier or alternation can apply to the whole unit. Groups may be capturing ( ), non-capturing (?: ), named, or atomic.

H

Hexadecimal escape (\xHH)
Matches a character by its two-digit hex code, e.g. \x41 for "A". Longer forms like \x{1F600} (PCRE) address higher code points.

I

Inline modifier
A flag switched on within the pattern itself, such as (?i) for case-insensitivity from that point on, or the scoped form (?i:...) that applies only inside the group.
Interval quantifier
Another name for the bounded quantifier {n,m} that specifies an explicit repetition count or range.

K

Kleene star (*)
The * quantifier, meaning "zero or more" of the preceding token. Named after Stephen Kleene; a* matches "", "a", "aa", and so on.

L

Lazy quantifier
A quantifier followed by ? that matches as few repetitions as possible, expanding only when forced. <.*?> stops at the first ">". Also called reluctant or non-greedy.
Line terminator
A character that ends a line — line feed \n, carriage return \r, and, in Unicode-aware engines, the separators U+2028/U+2029. It governs where . stops and where ^/$ match in multiline mode.
Literal
A character that matches itself with no special meaning, like the letters in cat. Metacharacters become literals when escaped.
Lookahead
A zero-width assertion (?=...) (positive) or (?!...) (negative) that tests what follows the current position without consuming it. Often stacked for rules like a strong-password check.
Lookaround
The umbrella term for lookahead and lookbehind — zero-width assertions that check the text around a position without including it in the match.
Lookbehind
A zero-width assertion (?<=...) (positive) or (?<!...) (negative) that tests what precedes the current position. Supported in modern JavaScript, Python, .NET, Java, and PCRE; some engines require it to be fixed-length.

M

Match
A substring that satisfies the pattern, or the act of finding one. The "whole match" is often numbered group 0, with capturing groups numbered from 1.
Match object
The result an engine returns for a successful match, exposing the matched text, its start/end positions, and any captured groups (e.g. Python's re.Match, JavaScript's array-like result).
Match position
The character offset in the input where a match (or a captured group) begins or ends, exposed as index/start()/end() depending on the language.
Metacharacter
A character with special meaning in a pattern rather than its literal self: . ^ $ * + ? ( ) [ ] { } | \ /. Escape one with a backslash to match it literally.
Modifier group
A scoped inline-flag group such as (?i:abc) that applies flags only to the enclosed subpattern, or (?-i:abc) to turn them off.
Multiline flag (m)
A flag that makes ^ and $ match at the start and end of every line, not just the whole string. It does not affect what the dot matches — that is the dotAll flag.

N

Named backreference
A reference to a named group by name rather than number, written \k<name> (JavaScript/.NET) or (?P=name) (Python).
Named capturing group
A capturing group given a label, written (?<year>\d{4}) (or (?P<year>...) in Python), so you can read it by name — far clearer than counting numbered groups.
Negated character class ([^ ])
A class beginning with ^ that matches any single character NOT listed, so [^0-9] matches one non-digit.
Nested group
A group contained within another group. Nesting affects capture numbering (outer opens first) and, when combined with quantifiers, is a common source of catastrophic backtracking.
Non-capturing group
A group written (?:...) that applies a quantifier or alternation without saving the match, keeping capture-group numbers clean. (?:ab)+ repeats "ab" without storing it.
Non-greedy
A synonym for lazy — a quantifier that matches as little as possible. See Lazy quantifier.
Nondeterministic finite automaton (NFA)
The backtracking engine model used by most mainstream flavors (PCRE, Java, .NET, JavaScript, Python). It supports rich features like backreferences and lookaround but can suffer catastrophic backtracking.

O

Octal escape
A character specified by its octal code, historically written \0, \012, or \o{...}. Ambiguous with backreferences in some flavors, so it is used sparingly.
Optional (?)
The ? quantifier, meaning "zero or one" of the preceding token. colou?r matches both "color" and "colour".
Overlapping matches
Matches that share characters. Standard engines consume characters as they go and so return non-overlapping matches; finding overlaps requires lookahead tricks or repeated searching from shifted positions.

P

Pattern
The regular expression itself — the sequence of literals, metacharacters, and constructs that describes the set of strings to match.
Pipe (|)
The symbol used for alternation. See Alternation.
Plus (+)
The quantifier meaning "one or more" of the preceding token. \d+ matches a run of at least one digit.
POSIX character class
A named class usable inside a bracket expression, such as [[:alpha:]], [[:digit:]], or [[:space:]]. Common in grep, sed, and PostgreSQL; not available in JavaScript. Source: POSIX — Regular Expressions (The Open Group)
Possessive dot-star
The construct .*+ (or an atomic (?>.*)) that consumes the rest of the line and refuses to give any of it back — a performance guard that also changes matching semantics.
Possessive quantifier
A quantifier followed by + (as in a*+ or \d++) that grabs its maximum and never gives characters back, like an atomic group. Useful for performance; unsupported in JavaScript and Python's re before 3.11. Source: PCRE2 — syntax
Precompilation
Compiling a pattern once and reusing it, rather than recompiling on each match. Improves performance in hot loops and is available in most languages via a compile/pattern object.
Previous-match anchor (\G)
An assertion matching at the end of the previous match (or the start of the search on the first attempt), used to tokenize contiguous input without gaps. Supported in PCRE, Java, .NET, and Ruby. Source: PCRE2 — syntax

Q

Quantifier
A construct specifying how many times the preceding token may repeat — *, +, ?, and {n,m}. Each has greedy, lazy, and (in some flavors) possessive modes.
Quantifier target
The single token or group a quantifier applies to — always the item immediately to its left. ab+ repeats only "b"; (ab)+ repeats "ab".
Question mark (?)
Depending on position, the optional quantifier (a?), the laziness modifier (a+?), or the opener of an extension group ((?:...), (?=...)).

R

Raw string
A source-code string in which backslashes are taken literally, so regex escapes survive intact — Python's r"\d+", C#'s @"\d+", Go's backtick strings. Avoids doubling every backslash.
RE2
Google's linear-time regex engine that guarantees no catastrophic backtracking by forbidding backreferences and lookaround. It powers Go's regexp, Google Sheets, and Search Console. Source: Google RE2 — syntax
Recursion
A pattern that refers to itself to match nested structures, written (?R) or (?1) in PCRE. It lets regex match balanced constructs that a non-recursive pattern cannot. Source: PCRE2 — pattern reference
ReDoS
Regular-expression Denial of Service — an attack that feeds crafted input to a backtracking-prone pattern to exhaust CPU. Mitigated by avoiding nested quantifiers, adding timeouts, or using an RE2-style engine. Source: OWASP — ReDoS
Regex engine
The software component that compiles a pattern and runs it against input. Its design (NFA vs DFA) and flavor determine which features and performance guarantees you get.
Regular expression
A compact, formal description of a text pattern used to search, validate, extract, and replace strings. Paste one into our explainer for a plain-English breakdown.
Reluctant quantifier
Java's term for a lazy quantifier — one suffixed with ? that matches the fewest repetitions.
Replacement string
The text substituted for each match in a replace operation. It can reference captured groups with $1/${name} (JavaScript, .NET, PHP) or \1/\g<name> (Python).

S

Search vs match
A distinction in some APIs: "match" anchors at the start of the string (Python's re.match) while "search" scans forward for the first match anywhere (re.search).
Start-of-string anchor (\A)
An assertion matching only at the very beginning of the input, unaffected by the multiline flag — unlike ^, which can match after internal newlines in multiline mode.
Sticky flag (y)
A JavaScript flag that anchors each match attempt to lastIndex, so matching succeeds only if it begins exactly there. Useful for tokenizers that scan a string piece by piece. Source: MDN — JavaScript RegExp
Subpattern
Any self-contained part of a larger pattern, usually a group. The term is common in PCRE documentation, where subpatterns can be numbered, named, or called as subroutines.
Subroutine call
A reuse of another group's subpattern by number or name, written (?1) or (?&name) in PCRE. Unlike a backreference, it re-runs the subpattern instead of matching the earlier text again. Source: PCRE2 — pattern reference
Substitution
Replacing matched text with a replacement string — the "replace" half of search-and-replace. Global substitution replaces every match.

T

Tempered greedy token
A pattern like (?:(?!END).)* that matches greedily but stops before a forbidden sequence, used to match "everything up to but not including" a delimiter without lazy matching.
Token
A single meaningful unit of a pattern — one literal, metacharacter, class, group, or quantified construct. Our explainer breaks a regex down token by token.

U

Unicode flag (u)
A flag that makes a pattern treat the input as Unicode code points (not UTF-16 units), enabling \u{...}, correct handling of astral characters, and \p{...} property escapes in JavaScript.
Unicode mode
The matching behavior in which a pattern operates on Unicode code points and honors Unicode properties and case folding, enabled by the u flag in JavaScript or on by default in Python 3. Source: The Unicode Standard
Unicode property escape (\p{...})
Matches characters by Unicode property or category, such as \p{L} (any letter), \p{N} (any number), or \p{Emoji}. Negate with \P{...}. Requires the u flag in JavaScript. Source: The Unicode Standard
Unrolling the loop
A hand-optimization that rewrites an alternation-inside-a-quantifier into a form the engine matches without excessive backtracking, improving performance on large inputs.

V

Verbose mode
See Extended mode — the whitespace-ignoring, comment-friendly layout mode enabled by the x flag.
Vertical bar
Another name for the pipe |, the alternation operator.

W

Whitespace shorthand (\s)
Matches a single whitespace character: space, tab \t, newline \n, carriage return \r, form feed, or vertical tab. Its negation \S matches any non-whitespace.
Word boundary (\b)
A zero-width assertion matching the position between a word character and a non-word character. \bcat\b matches "cat" as a whole word but not the "cat" in "category". Its negation is \B.
Word character shorthand (\w)
Matches a single "word character": letters, digits, and underscore — [A-Za-z0-9_] in ASCII mode. Its negation \W matches any non-word character.

Z

Zero-length match
A match that consumes no input, such as the result of a* against "b" or a bare anchor. Global matching steps forward one position after one to avoid an infinite loop.
Zero-width assertion
A construct that matches a position, consuming no characters — anchors (^, $, \b) and lookarounds all qualify. Several can stack at the same position.