Master Regex Patterns Every Developer Should Know with 120 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.
A single character of any kind except the newline character (\n). To make it also match newlines, use the s (dotall / single-line) flag, e.g. /foo.bar/s in JavaScript or re.DOTALL in Python.
[0-9] or the shorthand \d. \d is equivalent to [0-9] in ASCII; with Unicode (u flag in JS, default in Python 3 str) it matches any Unicode decimal digit, e.g. Arabic-Indic digits.
Any word character. In ASCII mode this is [A-Za-z0-9_]; in Unicode mode it also matches letters and digits from other scripts, and the underscore.
Any whitespace character: space, tab (\t), newline (\n), carriage return (\r), form feed (\f), and vertical tab (\v). In Unicode mode it can also match rare whitespace like the non-breaking space U+00A0.
Escape it with a backslash: \.. Inside a character class the dot is literal even without escaping, but \. still works and is the safe habit.
* matches zero or more occurrences, so the pattern is optional and may match the empty string. + matches one or more, so at least one occurrence is required.
It makes the token optional (zero or one occurrence). For example, colou?r matches both color and colour.
It matches as few characters as possible, expanding only as needed to satisfy the rest of the pattern. Useful for extracting content between the first and last delimiter, e.g. <.*?> matches a single tag.
Match the preceding token exactly three times. {3,} means three or more, and {3,5} means between three and five times inclusive.
They consume as many characters as possible while still allowing the overall pattern to succeed. They then backtrack if the remainder of the pattern fails.
The position at the start of the string. Inside a character class ([^abc]) it negates the class. With the m (multiline) flag ^ also matches after each newline.
The position at the end of the string. With the m flag it also matches before each newline. In JavaScript, without the m flag, $ still matches just before a final newline in some engines.
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge