Glossary
19 terms from "Regular Expressions: Stop Copy-Pasting Patterns You Can't Read." Look them up when you get stuck; the first mention in the text carries a hover definition.
| Term | Definition | Source |
|---|---|---|
| regular expression | A pattern used to match combinations of characters inside a string. | MDN: Regular expressions (JavaScript Guide) |
| literal | A character in a pattern that matches itself exactly, such as the letters in /cat/. | MDN: Regular expressions (JavaScript Guide) |
| metacharacter | A special character that is an instruction rather than a literal, such as . * + ? ^ $ [ ] ( ) or \. | MDN: Regular expressions (JavaScript Guide) |
| character class | A set in square brackets that matches exactly one character out of the listed characters, e.g. [abc]. | regular-expressions.info: Character Classes |
| range | A hyphenated shorthand inside a character class for a run of characters, e.g. [a-z] meaning any lowercase letter. | MDN: Character classes |
| negated character class | A character class beginning with ^ inside the brackets that matches any single character not in the set, e.g. [^a-z]. | regular-expressions.info: Character Classes |
| \d | A shorthand character class matching any digit; equivalent to [0-9]. | MDN: Character classes |
| \w | A shorthand character class matching any word character (a letter, digit, or underscore); equivalent to [A-Za-z0-9_]. | MDN: Character classes |
| \s | A shorthand character class matching a single whitespace character such as a space, tab, or newline. | MDN: Character classes |
| dot (.) | A metacharacter matching any single character except line terminators, unless the s (dotAll) flag is set. | MDN: Character classes |
| quantifier | A metacharacter that says how many times the preceding item repeats, such as * (0+), + (1+), ? (0 or 1), {n}, or {n,m}. | MDN: Quantifiers |
| greedy | The default behavior of a quantifier, matching as many repetitions as possible. | MDN: Quantifiers |
| lazy (non-greedy) | A quantifier followed by ? that matches as few repetitions as possible, e.g. .+?. | MDN: Quantifiers |
| anchor | A zero-width assertion that matches a position rather than a character, such as ^ (start), $ (end), or \b (word boundary). | MDN: Assertions (anchors and boundaries) |
| word boundary (\b) | A zero-length anchor matching the position between a word character and a non-word character (or a string edge). | regular-expressions.info: Word Boundaries |
| capturing group | A part of a pattern wrapped in parentheses that both bundles tokens and remembers the text it matched for later extraction. | MDN: Groups and backreferences |
| non-capturing group | A group written (?:...) that bundles tokens without storing what it matched in the result array. | MDN: Groups and backreferences |
| alternation (|) | The disjunction operator that matches one of several alternatives and has the lowest precedence in a pattern. | MDN: Disjunction (the | operator) |
| match array | The array returned by match without the g flag: index 0 is the whole match and later indices hold the captured groups, plus index and input properties. | MDN: String.prototype.match() |