Tools Cube

Command Palette

Search for a command to run...

Regex Library

Collection of useful regular expressions

Regex Tester
Edit the pattern, toggle flags, and see live matches highlighted.
/
/
0.02ms

Flags: gi

Supports capture groups and named groups. Example: Hello, $1 or $&.

source: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}/flags: gimatches: 2
Index
0
Groups
Index
19
Groups
Hand-picked patterns, ready to copy.
Email (simple, practical)
Web
Basic RFC-lite email matcher for most use cases.
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[A-Za-z]{2,}/g
URL (http/https)
Web
Matches common http/https URLs with optional query/hash.
/https?:\/\/[^\s/$.?#].[^\s]*/gi
Sample
Visit https://tariqul.dev or http://example.org?q=1#top
Slug (kebab-case)
Web
Lowercase letters, digits and hyphens.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/
Sample
projects, my-project-01
HTML tag
Web
Find HTML tags with attributes.
/<("[^"]*"|'[^']*'|[^'">])*>/g
Sample
<div class='box'>Hello</div>
YouTube Video ID
Web
Extract 11-char YouTube video ID from URL.
/(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([A-Za-z0-9_-]{11})/i
Sample
https://youtu.be/abc123XYZ09
Integer (signed)
Numbers
Optional leading +/-, then digits.
/^[+-]?\d+$/
Sample
-42, 0, +99
Number (int/float)
Numbers
Optional sign, optional decimals.
/^[+-]?(?:\d+\.?\d*|\.\d+)$/
Sample
3, -2.5, .75, +10.0
Currency (BDT style)
Numbers
Digits with optional commas and decimals.
/^\d{1,3}(?:,\d{3})*(?:\.\d{1,2})?$/
Sample
1,200,500.00
Roman numeral
Numbers
Match Roman numerals up to 3999.
/^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i
Sample
XIV, MMXXV
Percentage (0-100%)
Numbers
Number between 0–100 with % sign.
/^(100(\.0+)?|[0-9]?\d(\.\d+)?)%$/
Sample
25%, 99.5%, 100%
Strong password (8+ with mix)
Security
At least 8 chars, upper, lower, number, symbol.
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/
Sample
Aa1!aaaa
Hex color (#RGB/#RRGGBB)
Security
3 or 6 hex digits after #.
/^#(?:[0-9a-fA-F]{3}){1,2}$/
Sample
#0fa, #0F0F0F
JWT token
Security
Three base64url encoded parts separated by dots.
/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/
Sample
eyJhbGciOi...abc.def.ghi
UUID v4
System
Canonical lowercase/uppercase variants.
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/
Sample
123e4567-e89b-12d3-a456-426614174000
IPv4 address
System
0–255 dot-separated quads.
/^(?:25[0-5]|2[0-4]\d|1?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/
Sample
192.168.0.1
IPv6 address
System
Matches most IPv6 formats.
/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(::1)|::)$/i
Sample
2001:0db8:85a3:0000:0000:8a2e:0370:7334
MAC address
System
6 pairs of hex digits separated by : or -.
/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
Sample
00:1A:2B:3C:4D:5E
Trim extra spaces (find)
Text
Multiple spaces for replacement.
/\s{2,}/g
Sample
hello world
Words (ASCII)
Text
Word tokens split.
/\b\w+\b/g
Sample
This is a test.
Hashtags
Text
Find #hashtags in text.
/#\w+/g
Sample
Loving #ToolsCube and #regex
Mentions (@username)
Text
Find Twitter/Instagram style mentions.
/@\w+/g
Sample
Thanks @tariqul_dev
Bangladesh mobile (+880 / 01)
Bangla
Typical Bangladeshi mobile formats.
/^(?:\+?88)?01[3-9]\d{8}$/
Sample
+8801712345678, 01712345678
Bangla letters
Bangla
Matches Bangla letters (একাধিক).
/[\u0980-\u09FF]+/g
Sample
আমার সোনার বাংলা
Bangla numbers
Bangla
০–৯ বাংলা সংখ্যা match করে।
/[০-৯]+/g
Sample
১২৩৪৫৬৭৮৯০
Favorites
Save and reuse your most common patterns.
No favorites yet. Click Save Favorite above to store the current pattern.
Regex Cheatsheet
Common tokens, anchors & quantifiers (JS flavor).
Anchors
  • ^ start of string
  • $ end of string
  • \b word boundary
Character Classes
  • \d digit, \w word, \s whitespace
  • . any char (except newline unless s)
  • [abc] set, [^abc] negated
Groups & Quantifiers
  • ( ) capture, (?: ) non-capture
  • (?<name> ) named capture
  • ?, *, +, {m,n} (add ? for lazy)
Regex Library - Tools Cube