Skip to content

Regex Cheatsheet

Regular expression syntax reference with examples. Click any syntax to copy.

Character Classes

.Any character except newline
e.g. a.cCopy
\dDigit [0-9]
e.g. \d+Copy
\DNon-digit [^0-9]
e.g. \D+Copy
\wWord character [a-zA-Z0-9_]
e.g. \w+Copy
\WNon-word character
e.g. \W+Copy
\sWhitespace [\t\n\r\f\v ]
e.g. \s+Copy
\SNon-whitespace
e.g. \S+Copy
[abc]Character set (a, b, or c)
e.g. [aeiou]Copy
[^abc]Negated set (not a, b, or c)
e.g. [^0-9]Copy
[a-z]Range (a through z)
e.g. [a-zA-Z]Copy

Anchors

^Start of string/line
e.g. ^HelloCopy
$End of string/line
e.g. end$Copy
\bWord boundary
e.g. \bword\bCopy
\BNon-word boundary
e.g. \Bword\BCopy

Quantifiers

*Zero or more
e.g. ab*Copy
+One or more
e.g. ab+Copy
?Zero or one (optional)
e.g. colou?rCopy
{n}Exactly n times
e.g. \d{3}Copy
{n,}n or more times
e.g. \d{2,}Copy
{n,m}Between n and m times
e.g. \d{2,4}Copy
*?Lazy zero or more
e.g. a.*?bCopy
+?Lazy one or more
e.g. a.+?bCopy

Groups & References

(abc)Capturing group
e.g. (\d{3})-\d{4}Copy
(?:abc)Non-capturing group
e.g. (?:https?|ftp)://Copy
(?<name>abc)Named capturing group
e.g. (?<year>\d{4})Copy
\1Backreference to group 1
e.g. (\w+)\s\1Copy
|Alternation (OR)
e.g. cat|dogCopy

Lookaheads & Lookbehinds

(?=abc)Positive lookahead
e.g. \d(?=px)Copy
(?!abc)Negative lookahead
e.g. \d(?!px)Copy
(?<=abc)Positive lookbehind
e.g. (?<=\$)\d+Copy
(?<!abc)Negative lookbehind
e.g. (?<!\$)\d+Copy

Flags

gGlobal (match all)
e.g. /abc/gCopy
iCase insensitive
e.g. /abc/iCopy
mMultiline (^ and $ per line)
e.g. /^abc/mCopy
sDotall (. matches newline)
e.g. /a.b/sCopy

Common Patterns

^[\w.-]+@[\w.-]+\.\w+$Email address
https?://[\w.-]+URL
e.g. https://example.comCopy
\d{3}-\d{3}-\d{4}US phone number
e.g. 555-123-4567Copy
#([a-fA-F0-9]{3}){1,2}\bHex color code
e.g. #ff00ffCopy
\b\d{1,3}(\.\d{1,3}){3}\bIPv4 address
e.g. 192.168.1.1Copy

How to Use Regex Cheatsheet

  1. Paste your code or data into the input field
  2. Choose the operation you want to perform
  3. View the formatted, validated, or transformed output
  4. Copy the result or download if available

Why Use Regex Cheatsheet?

Developer tools on FreeTools.one are designed to replace the dozen browser tabs you'd otherwise need. JSON formatting, regex testing, JWT decoding, SQL formatting, diff checking — everything runs in your browser with zero configuration. There's nothing to install, no CLI to learn, no Docker containers to spin up. Each tool provides professional-grade output with syntax highlighting, error detection, and one-click copy. Your code and data never leave your device because all processing happens client-side. These tools are built by developers, for developers, with the exact features you need: customizable indentation, multiple output formats, real-time validation, and keyboard shortcuts. They're fast enough for quick checks during coding sessions and powerful enough for production data transformation.

  • No installation needed — works directly in your browser
  • Client-side processing keeps your code private
  • Professional-grade formatting and validation
  • Save hours of manual coding and debugging

Frequently Asked Questions

Is my code sent to a server?

No. All processing happens in your browser. Your code never leaves your device.

Does it support syntax highlighting?

Yes. Output is displayed with proper formatting for easy reading.

Can I use this for production code?

Absolutely. The output is clean and ready for production use.

Related Tools You Might Like