T
Tooltastic
Regex Cheatsheet – Regular Expression Reference | Tooltastic
Regex Reference

Regex Cheatsheet

A complete regular expression reference — search, filter, and copy patterns instantly

50+ Patterns Searchable Regex Tester
patterns

What is a Regular Expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is used to find, match, and manipulate text — from simple word searches to complex validation of emails, URLs, and phone numbers.

Why Learn Regex?

Regex is a universal skill used in every programming language, text editor, and command-line tool. It enables you to validate form input, parse log files, perform find-and-replace operations at scale, and extract structured data from raw text.

Regex in Different Languages

JavaScript uses /pattern/flags literals, Python uses the re module, PHP uses preg_match(), Java uses Pattern.compile(). While the core syntax is shared, each language has slight variations — use the "Try it" links to test patterns in the browser.

Frequently Asked Questions about Regex

Everything you need to know about regular expressions

A greedy quantifier (*, +, {n,m}) matches as much as possible while still allowing the overall pattern to succeed. A lazy (non-greedy) quantifier (*?, +?, {n,m}?) matches as little as possible. Example: given "<b>bold</b>", the pattern <.*> (greedy) matches the entire string, while <.*?> (lazy) matches only "<b>".

+ means "one or more" — the preceding element must appear at least once. * means "zero or more" — the preceding element may appear zero times (it is optional). For example, \d+ requires at least one digit, while \d* allows a string with no digits at all.

In regex, a bare dot (.) matches any character except newline. To match a literal dot, you must escape it with a backslash: \. So to match "example.com" exactly, use the pattern example\.com. In JavaScript string literals you write it as "example\.com" or /example\.com/.

The core syntax (anchors, character classes, quantifiers) is largely consistent across modern languages. However, there are important differences: lookbehind support varies (JavaScript ES2018+, Python yes, older engines no), named groups use different syntax ((?<name>) vs (?P<name>)), and some engines use different escape rules. Always test patterns in the target language.