K
Konvertio.
Encoders & Decoders
Formatters & Linters
Generators
Converters
Text Tools
Blog
K
Konvertio.

Free developer tools — encoders, formatters, generators & more. No signup, no data processing on our servers.

Encoders

Base64 EncoderJWT DecoderAES EncryptHMAC GeneratorHash Generator

Formatters

JSON FormatterSQL FormatterXML FormatterCSS FormatterJSONPath Tester

Generators

Password GeneratorQR CodeToken GeneratorUUID GeneratorOTP Generator

Converters

JSON ↔ YAMLJSON → TypeScriptHTML → JSXDocker → ComposeSQL → MongoDB

Text Tools

Word CounterHTTP Status CodesPassword StrengthMath EvaluatorMIME Lookup

© 2026 Konvertio. All tools are free to use.

PrivacyAboutTermsBlog
HomeBlogRegex Cheat Sheet for Developers: Common Patterns
April 4, 2026 2 min readUpdated Apr 9, 2026

Regex Cheat Sheet for Developers: Common Patterns

regexcheat-sheetjavascriptpythonbackend

image

Regex Fundamentals

Regular expressions (regex) are patterns used to match character combinations in strings. Supported in JavaScript, Python, Go, Java, Ruby, PHP, and virtually every other language.

Core Syntax Quick Reference

TokenMeaning
.Any character except newline
\dDigit (0–9)
\wWord character (a-z, A-Z, 0-9, _)
\sWhitespace (space, tab, newline)
^Start of string
$End of string
*0 or more
+1 or more
?0 or 1 (optional)
{n,m}Between n and m times
[abc]Character class (a, b, or c)
[^abc]Negated class (not a, b, or c)
`(ab)`
(?:...)Non-capture group
(?=...)Positive lookahead

Common Patterns

Email Address

^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$

URL (HTTP/HTTPS)

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)

IPv4 Address

^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Date (YYYY-MM-DD)

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$

Hex Color Code

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

UUID v4

^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

Slug (URL-safe string)

^[a-z0-9]+(?:-[a-z0-9]+)*$

Strong Password

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

Requires: 1 lowercase, 1 uppercase, 1 digit, 1 special character, min 8 chars.

Practical JavaScript Examples

// Test a pattern
const emailRegex = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/;
console.log(emailRegex.test('user@example.com')); // true

// Extract all matches
const text = 'Call 555-867-5309 or 800-555-1212';
const phones = text.match(/(\d{3}[-.]\d{3}[-.]\d{4})/g);
// ['555-867-5309', '800-555-1212']

// Replace with capture groups
'2026-04-09'.replace(/^(\d{4})-(\d{2})-(\d{2})$/, '$2/$3/$1');
// '04/09/2026'

Flags Reference

FlagMeaning
gGlobal — find all matches
iCase-insensitive
mMultiline — ^ and $ match line starts/ends
sDotall — . matches newline too

Test Your Regex Online

Use the free Regex Tester on konvertio.app — enter your pattern and test string, see matches highlighted in real time, and understand capture groups at a glance.

Back to all posts
Share
Twitter / X LinkedIn Facebook
Tags
regexcheat-sheetjavascriptpythonbackend
Resources
All ToolsJSON FormatterBase64 EncoderJWT DecoderUUID GeneratorAll Posts
Follow
Twitter / X LinkedIn RSS Feed Newsletter