Common regular expressions for validation and parsing
Validates standard email addresses
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Matches HTTP and HTTPS URLs
^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$https://example.comhttp://www.example.com/path?query=valueUS phone numbers with various formats
^(\+1)?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$(555) 123-4567+1 555-123-4567Validates IPv4 addresses
^((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]?)$192.168.1.1255.255.255.0Matches hex color codes
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$#FF5733#FFFValidates Visa credit card numbers
^4[0-9]{12}(?:[0-9]{3})?$41111111111111114012888888881881ISO 8601 date format
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$2024-01-152024-12-3124-hour time format
^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?$14:3009:05:30Alphanumeric username, 3-16 chars
^[a-zA-Z0-9_-]{3,16}$user_nameUser-123Min 8 chars, uppercase, lowercase, number, special char
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Password123!Str0ng@PassValidates UUID v4 format
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$550e8400-e29b-41d4-a716-446655440000123e4567-e89b-12d3-a456-426614174000Matches HTML tags
<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)<div>content</div><img src="image.jpg" />^ - Start of string
$ - End of string
. - Any character
* - 0 or more
+ - 1 or more
? - 0 or 1
\d - Digit
\w - Word character
\s - Whitespace
[abc] - Character set
(x|y) - x or y
{n} - Exactly n times