Searchable regular expression cheat sheet organized by category. Covers anchors, quantifiers, character classes, groups, flags, and common patterns with one-click copy.
Enter a pattern or keyword in the search field, or click a category button (Anchors, Quantifiers, etc.) to narrow down the list.
Check each pattern's description, usage example, and expected output to understand how it works.
Click the copy button on any card to copy the pattern to your clipboard for immediate use in your code or terminal.
/^Hello/.test('Hello World')true/World$/.test('Hello World')true'cat catalog'.match(/\bcat\b/g)['cat']'catalog'.match(/\Bcat\B/g)null'color colour'.match(/colou*r/g)['color', 'colour']'ac abc'.match(/ab+c/g)['abc']'color colour'.match(/colou?r/g)['color', 'colour']'aaa aa a'.match(/a{2}/g)['aa', 'aa']'aaa aa a'.match(/a{2,}/g)['aaa', 'aa']'aaaa aaa aa a'.match(/a{2,3}/g)['aaa', 'aaa', 'aa']'abc 123'.match(/\d+/g)['123']'abc 123'.match(/\D+/g)['abc ']'hello world_2'.match(/\w+/g)['hello', 'world_2']'hello world'.match(/\W+/g)[' ']'hello world'.match(/\s+/g)[' ']'hello world'.match(/\S+/g)['hello', 'world']'cat bat hat'.match(/[cbh]at/g)['cat', 'bat', 'hat']'Hello World'.match(/[a-z]+/g)['ello', 'orld']'cat 123'.match(/[^\d ]+/g)['cat']'2024-03-15'.replace(/(\d{4})-(\d{2})-(\d{2})/, '$2/$3/$1')'03/15/2024''foobar foobaz'.match(/foo(?:bar|baz)/g)['foobar', 'foobaz']'100px 200em'.match(/\d+(?=px)/g)['100']'100px 200em'.match(/\d+(?!px)/g)['10', '200']'$100 €200'.match(/(?<=\$)\d+/g)['100']'$100 200'.match(/(?<!\$)\d+/g)['200']'aaa'.match(/a/g)['a', 'a', 'a']'Hello HELLO'.match(/hello/gi)['Hello', 'HELLO']'line1\nline2'.match(/^line/gm)['line', 'line']'foo\nbar'.match(/foo.bar/s)['foo\nbar']'\u{1F600}'.match(/./u)[0].length2'cat bat'.match(/.at/g)['cat', 'bat']'cat dog bird'.match(/cat|dog/g)['cat', 'dog']'3.14'.match(/3\.14/)['3.14']'2024-03-15'.match(/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})/).groupsTools.Reference.RegexCheatsheet.patterns.namedGroup.output/.+@.+/.test('user@example.com')true/https?:\/\/.+/.test('https://example.com')true/0\d{1,4}-\d{1,4}-\d{4}/.test('03-1234-5678')true/valid IPv4 pattern/.test('192.168.1.1')true/\d{4}[-\/]\d{2}[-\/]\d{2}/.test('2024-03-15')true'color: #fff and #1a2b3c'.match(/#[0-9a-fA-F]{3,6}/g)['#fff', '#1a2b3c']/\d{3}-\d{4}/.test('123-4567')trueRegex Cheat Sheet is a quick reference for regular expression syntax. It covers all major constructs including anchors, quantifiers, character classes, capturing groups, lookahead/lookbehind assertions, and flags. Common real-world patterns for email, URL, IP address, and date formats are also included. Each entry provides a practical example with expected output.
* matches 0 or more occurrences, while + requires at least 1. For example, /ab*c/ matches 'ac', 'abc', 'abbc', but /ab+c/ only matches 'abc', 'abbc' — not 'ac'.
A capturing group stores the matched text and makes it available as $1, $2, etc. in replacements or match.groups. A non-capturing group only groups for precedence and quantifiers without storing the match, which is more efficient.
Lookahead (?=...) asserts that the pattern must follow the current position. Lookbehind (?<=...) asserts that the pattern must precede the current position. Neither consumes characters, so they are called zero-width assertions.
The g (global) flag makes the regex engine find all matches in the string instead of stopping after the first. Without g, methods like String.match() return only the first match.
Escape it with a backslash. For example, use \. to match a literal dot, \( to match a literal parenthesis, and \* to match a literal asterisk. Without the backslash, . matches any character.