String validation and regex patterns for text processing, email validation, URL checking, and format verification.
173 code snippets available
Checks if string is empty or whitespace only.
Capitalizes first letter of string.
Truncates string with ellipsis.
Converts string to URL-friendly slug.
Counts words in a string.
Reverses a string.
Checks if string reads same forwards and backwards.
Min 8 chars, 1 upper, 1 lower, 1 num, 1 special.
Min 8 chars, 1 letter, 1 number.
Standard 4-digit PIN.
Standard 6-digit PIN / OTP.
32+ alphanumeric characters.
International format (+14155552671).
Matches (555) 555-5555 or 555-555-5555.
UK Mobile number format.
+91 or 10-digit mobile.
5 digit or 5+4 (12345-6789).
Standard UK postcode format.
Format A1A 1A1.
6 digit pincode.
Valid latitude, longitude pair.
-90 to 90.
-180 to 180.
3-16 chars, alphanumeric, underscore, hyphen.
Standard Twitter handle (w/ optional @).
Valid social media hashtag.
Extracts ID or validates URL.
Common email validation (lighter than RFC).
SEO-friendly URL part.
#RGB or #RRGGBB.
Universal Unique Identifier.
32 char hex hash.
64 char hex hash.
Valid Base64 encoding.
Basic check for {} or [].
A-Z case insensitive.
A-Z and 0-9.
Digits only.
Strings without spaces/tabs.
Australian mobile format.
German phone format.
French phone format.
Japanese phone format.
Brazilian phone format.
Valid Instagram username.
Valid TikTok username.
LinkedIn profile link.
Valid GitHub username.
Discord username format.
Telegram username.
Base64 data URI format.
Magnet link format.
rgb(255,255,255) format.
rgba with alpha channel.
hsl(360,100%,100%) format.
#RRGGBBAA with alpha.
ISO 3166-1 alpha-2.
ISO 3166-1 alpha-3.
ISO 639-1 (e.g. en, fr).
Format: en_US, fr_FR.
10-digit book identifier.
13-digit book identifier.
Product barcode.
US product code.
Amazon product ID.
Valid CSS class selector.
Valid HTML id attribute.
Valid CSS unit (px, em, rem, %).
00-FF opacity value.
Valid env var name.
Valid MIME type format.
YouTube channel identifier.
Spotify resource URI.
Apple Music track ID.
Mexican phone format.
Korean phone format.
Russian phone format.
Italian phone format.
Spanish phone format.
Dutch phone format.
Polish phone format.
Swedish phone format.
Swiss phone format.
UAE phone format.
Singapore phone format.
South African phone format.
Nigerian phone format.
Egyptian phone format.
Pakistani phone format.
Pinterest profile URL.
Valid Snapchat username.
Reddit username format.
Valid subreddit format.
Valid Twitch username.
Medium username format.
Mastodon username@instance.
Bluesky username format.
Instagram Threads username.
Facebook page link.
Medical diagnosis code.
Clinical terminology code.
Drug identifier code.
National Drug Code.
University course code.
Grade point average 0.0-4.0.
SAT score 400-1600.
Stock Keeping Unit.
E-commerce order format.
UPS tracking number.
FedEx tracking number.
USPS tracking number.
Promotional code format.
Coupon format.
Steam user ID.
64-bit Steam ID.
Xbox Live gamertag.
PlayStation Network ID.
Nintendo Switch friend code.
Epic Games username.
Riot Games ID format.
WhatsApp click-to-chat.
Signal phone format.
Slack channel name.
Slack user identifier.
Microsoft Teams meeting.
Zoom meeting identifier.
3-letter airport code.
4-letter airport code.
Airline flight number.
Passenger Name Record.
13-digit e-ticket.
Loyalty program ID.
Digital Object Identifier.
PubMed article identifier.
arXiv paper identifier.
Basic chemical formula.
Chemical registry number.
Chemical identifier key.
Federal court case.
US patent number.
USPTO trademark.
Video aspect ratio.
Video resolution.
FPS format.
Bitrate format.
HH:MM:SS:FF format.
MM:SS format.
Named CSS color.
Mobile browser detection.
Search engine bot.
Windows version string.
macOS version string.
iOS version format.
Android version.
Temp email domains.
Business email format.
.edu email address.
.gov email address.
Valid YAML key.
Valid TOML key.
INI file section.
.env variable name.
Valid npm package.
Valid Python package.
Valid gem name.
Valid Rust crate.
Maven artifact format.
Valid NuGet package.
Standard log levels.
Syslog priority format.
String boolean value.
Null-like string values.
Hexadecimal string.
Our string & regex validation snippets are designed to handle the most common validation scenarios you'll encounter in modern software development. Each snippet is thoroughly tested, optimized for performance, and follows industry best practices.
All validators are available in multiple programming languages including JavaScript, TypeScript, Python, Go, PHP, C#, and Rust. Simply copy the code snippet, adapt it to your specific needs, and integrate it into your project. Every snippet is MIT licensed—free for personal and commercial use.