.*
LIBRERIA DI PATTERN

Libreria di Pattern Regex

Espressioni regolari verificate per le attività di programmazione quotidiane. Un clic per testare o copiare.

Email & Contact

Email Address

Matches standard email addresses

[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
e.g. user@example.com

Phone (US)

Matches US phone number formats

\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
e.g. (555) 123-4567

Phone (International)

Matches international phone formats

\+?\d{1,4}[-.\s]?\(?\d{1,3}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}
e.g. +1 (555) 123-4567

Web & URLs

URL (HTTP/HTTPS)

Matches HTTP and HTTPS URLs

https?://[\w.-]+(?:\.[a-zA-Z]{2,})(?:/[^\s]*)?
e.g. https://example.com/path

Domain Name

Matches domain names

(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}
e.g. sub.example.com

IP Address (IPv4)

Validates IPv4 addresses

\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b
e.g. 192.168.1.1

Slug (URL-friendly)

Matches URL slugs

^[a-z0-9]+(?:-[a-z0-9]+)*$
e.g. my-blog-post

Dates & Times

Date (YYYY-MM-DD)

ISO 8601 date format

\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
e.g. 2024-01-15

Date (MM/DD/YYYY)

US date format

(?:0[1-9]|1[0-2])/(?:0[1-9]|[12]\d|3[01])/\d{4}
e.g. 01/15/2024

Date (DD/MM/YYYY)

European date format

(?:0[1-9]|1[0-2])/(?:0[1-9]|[12]\d|3[01])/\d{4}
e.g. 15/01/2024

Time (24h)

24-hour time format

(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?
e.g. 14:30:00

Time (12h)

12-hour time with AM/PM

(?:0?[1-9]|1[0-2]):[0-5]\d\s?(?:AM|PM|am|pm)
e.g. 2:30 PM

Numbers & Finance

Integer

Matches positive and negative integers

-?\d+
e.g. -42, 0, 123

Decimal Number

Matches decimal numbers

-?\d+\.\d+
e.g. 3.14, -0.5

Currency (USD)

US dollar amounts

\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?
e.g. $1,234.56

Credit Card

Matches Visa, MC, Amex, Discover

\b(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b
e.g. 4111-1111-1111-1111

Percentage

Matches percentage values

\d+(?:\.\d+)?%
e.g. 42.5%

Security & Validation

Strong Password

Min 8 chars, upper, lower, digit, special

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

Hex Color

Matches hex color codes

#(?:[0-9a-fA-F]{3}){1,2}\b
e.g. #ff6600, #f60

UUID v4

Matches UUID version 4

[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}
e.g. 550e8400-e29b-41d4-a716-446655440000

JWT Token

Matches JWT tokens

eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*
e.g. eyJhbGci...

File & System

File Extension

Matches file extensions

\.[a-zA-Z0-9]{1,10}$
e.g. .pdf, .js, .html

File Path (Unix)

Unix file paths

(?:/[\w.-]+)+
e.g. /usr/local/bin/node

File Path (Windows)

Windows file paths

[A-Z]:\\(?:[\w.-]+\\)*[\w.-]+
e.g. C:\Users\name\file.txt

Semantic Version

SemVer version strings

\d+\.\d+\.\d+(?:-[\w.]+)?(?:\+[\w.]+)?
e.g. 1.2.3-beta.1

Text Processing

HTML Tags

Matches opening and closing HTML tags

<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s[^>]*)?\/?>
e.g. <div class="x">

Markdown Links

Matches [text](url) markdown links

\[([^\]]+)\]\(([^)]+)\)
e.g. [click](http://ex.com)

Quoted String

Matches single or double quoted strings

"[^"]*"|'[^']*'
e.g. "hello" or 'world'

Whitespace Trim

Leading and trailing whitespace

^\s+|\s+$
e.g. trim me

Duplicate Words

Finds consecutive duplicate words

\b(\w+)\s+\1\b
e.g. the the

Empty Lines

Matches blank lines

^\s*$
e.g. (empty line)

Programming

Variable Name

Valid JS/Python/Java variable names

[a-zA-Z_$][a-zA-Z0-9_$]*
e.g. myVar, _count, $el

CSS Class

CSS class selectors

\.[a-zA-Z_-][a-zA-Z0-9_-]*
e.g. .btn-primary

Single-line Comment

C-style single-line comments

\/\/.*$
e.g. // comment

Multi-line Comment

C-style block comments

\/\*[\s\S]*?\*\/
e.g. /* comment */

Don't see the pattern you need?

Build Your Own →