SQL Regex Patterns & Examples
85 real-world SQL regex patterns for MySQL, PostgreSQL, SQLite, BigQuery, Snowflake, and MongoDB. Copy-paste ready examples for data validation, extraction, and cleaning.
Extract Email from MySQL Users Table with Regex
Learn how to extract and validate email addresses from MySQL users table using REGEXP. SQL query examples with regex patterns.
Validate Email Address in PostgreSQL with Regex
Use PostgreSQL ~ operator to validate email addresses. SQL examples for email validation with regex in Postgres databases.
Validate Email in SQLite Using REGEXP
Validate email addresses in SQLite using the REGEXP operator. Setup instructions and SQL examples for email format checking.
Validate Email Address in SQL Server with PATINDEX
Validate email format in SQL Server using PATINDEX or LIKE patterns. T-SQL examples for email validation in SQL Server.
Extract Email Domain from MySQL Column with Regex
Use MySQL REGEXP or SUBSTRING_INDEX to extract the domain part from email addresses. SQL examples for email domain extraction.
Extract Username Part from Email in MySQL with Regex
Extract the username portion before @ from email addresses stored in MySQL. SQL examples using REGEXP_SUBSTR.
Find Duplicate Email Records in MySQL with Regex Filter
Detect duplicate valid email addresses in MySQL using GROUP BY with REGEXP validation. SQL deduplication query examples.
Extract Email Domain in PostgreSQL with regexp_replace
Use PostgreSQL regexp_replace to extract the domain part from email address columns. SQL examples for email domain analysis.
Match Phone Number Format in MySQL with REGEXP
Validate and filter phone numbers in MySQL using REGEXP. Examples for US, international, and custom phone formats in SQL.
Extract Phone Number from Text Column in PostgreSQL
Use PostgreSQL regexp_matches to extract phone numbers from text fields. SQL examples for phone number extraction.
Normalize Phone Numbers in PostgreSQL with regexp_replace
Use PostgreSQL regexp_replace to strip non-numeric chars and normalize phone number formats. SQL normalization examples.
Validate Phone Number in SQLite Using REGEXP
Validate phone number formats in SQLite using custom REGEXP function. Setup and SQL examples for phone validation.
Validate Phone Number in SQL Server with PATINDEX
Use SQL Server PATINDEX to validate phone number formats in T-SQL. Examples for phone number checking in MSSQL databases.
Validate US Phone Number in PostgreSQL with Regex
Use PostgreSQL regex to validate US phone number formats including area code. SQL examples for NANP phone validation.
Validate International Phone Number in MySQL with REGEXP
Use MySQL REGEXP to validate international phone numbers in E.164 format. SQL examples for global phone number validation.
Deduplicate Phone Records by Normalizing Format in MySQL
Normalize phone number formats using REGEXP_REPLACE in MySQL then deduplicate. SQL examples for phone deduplication.
Validate URL Format in MySQL Using REGEXP
Check if a URL column contains valid HTTP/HTTPS URLs in MySQL using REGEXP. SQL query examples for URL validation.
Extract URLs from Text Column in PostgreSQL with Regex
Use PostgreSQL regexp_matches to extract all URLs from text columns. SQL examples for URL extraction from unstructured data.
Validate URL Format in SQL Server Using LIKE Pattern
Use SQL Server LIKE patterns to validate URL formats in T-SQL. Examples for HTTP/HTTPS URL validation in MSSQL tables.
Extract Domain from URL in MySQL with Regex
Use MySQL REGEXP_SUBSTR to extract the domain name from URL columns. SQL examples for URL domain extraction and analytics.
Extract Domain from URL in PostgreSQL Using Regex
Use PostgreSQL regexp_matches to extract domain names from URL columns. SQL examples for URL domain parsing.
Find Invalid URLs in MySQL with REGEXP
Use MySQL REGEXP to identify rows with malformed or broken URL values in your database. SQL URL audit examples.
Validate Date Format YYYY-MM-DD in MySQL Using REGEXP
Use MySQL REGEXP to validate YYYY-MM-DD date format stored as strings. SQL examples for date string format validation.
Check Date Format in PostgreSQL with Regex
Validate date strings in text columns using PostgreSQL regex. SQL examples for YYYY-MM-DD date format checks in Postgres.
Extract Year from Date String in MySQL with Regex
Extract year component from date strings stored in MySQL columns using REGEXP_SUBSTR. SQL examples for year extraction.
Extract Date Parts from Text in PostgreSQL with Regex
Use PostgreSQL regexp_matches to extract year, month, and day from date strings in text columns. SQL examples.
Validate MM/DD/YYYY Date Format in MySQL with REGEXP
Use MySQL REGEXP to validate MM/DD/YYYY date format stored as strings. SQL examples for US date format checking.
Check Date Format in SQL Server with PATINDEX
Use SQL Server PATINDEX to validate date string formats in T-SQL. Examples for YYYY-MM-DD date format checking in MSSQL.
Validate IP Address in MySQL with REGEXP
Use MySQL REGEXP to validate IPv4 addresses in your database. SQL query examples to filter valid and invalid IP records.
Validate IPv4 Address in PostgreSQL Using Regex
Validate IPv4 addresses in PostgreSQL using the regex ~ operator. SQL examples for IP address format validation in Postgres.
Validate IPv6 Address Format in MySQL with REGEXP
Use MySQL REGEXP to validate IPv6 address formats in database columns. SQL examples for IPv6 address validation queries.
Validate IPv6 Address in PostgreSQL Using Regex
Validate IPv6 address format in PostgreSQL using regex operators. SQL examples for IPv6 address validation in Postgres.
Check IP Address Format in SQLite with REGEXP
Validate IPv4 address formats in SQLite using the custom REGEXP operator. Setup and SQL examples for IP validation.
Validate Username Format in MySQL with REGEXP
Use MySQL REGEXP to validate usernames with alphanumeric and underscore characters. SQL examples for username enforcement.
Check Username Format in PostgreSQL Using Regex
Validate username strings in PostgreSQL using regex operators. SQL query to find usernames with invalid characters or wrong length.
Find Invalid Usernames in MySQL with REGEXP
Use MySQL REGEXP to detect usernames with special characters or wrong length in your users table. SQL audit examples.
Extract Price and Currency from MySQL Column with Regex
Use MySQL REGEXP_SUBSTR to extract price values with currency symbols from text columns. SQL regex examples for price extraction.
Extract Currency Amount from PostgreSQL Text with Regex
Use PostgreSQL regexp_matches to extract monetary values from text columns. SQL examples for price and currency extraction.
Validate Price Format in MySQL with REGEXP
Use MySQL REGEXP to validate decimal price formats like 9.99 or 1000.00 in a products table. SQL data validation examples.
Validate Decimal Price Format in PostgreSQL Using Regex
Use PostgreSQL regex to validate that price columns contain valid decimal number formats. SQL validation query examples.
Detect Duplicate Records in PostgreSQL Using Regex
Find duplicate rows in PostgreSQL combining regex pattern matching with GROUP BY. SQL examples for deduplication with regex.
Find Duplicate Emails in PostgreSQL with Regex Validation
Detect duplicate valid email addresses in PostgreSQL using GROUP BY with regex filtering. SQL deduplication examples.
Find Duplicate Records in SQL Server with LIKE Pattern
Detect and find duplicate data records in SQL Server using LIKE pattern matching and GROUP BY. T-SQL deduplication examples.
Find Duplicate Values in SQLite Using REGEXP
Detect duplicate column values in SQLite using REGEXP with GROUP BY. SQL examples for data deduplication in SQLite.
Strip HTML Tags from Column in MySQL with REGEXP_REPLACE
Remove HTML tags from text columns in MySQL 8.0+ using REGEXP_REPLACE. SQL examples for cleaning HTML content in database.
Remove HTML Tags from PostgreSQL Column Using regexp_replace
Strip HTML tags from text columns in PostgreSQL using regexp_replace. SQL examples for HTML content cleanup in Postgres.
Remove Extra Whitespace from MySQL Column with REGEXP_REPLACE
Use MySQL REGEXP_REPLACE to remove leading, trailing, and multiple consecutive spaces from text columns.
Trim and Remove Extra Whitespace in PostgreSQL with Regex
Use PostgreSQL regexp_replace to clean up extra whitespace in text columns. SQL examples for whitespace normalization.
Check Password Strength in MySQL with REGEXP
Use MySQL REGEXP to validate password complexity: uppercase, lowercase, digits, special characters. SQL audit query examples.
Validate Strong Password in PostgreSQL Using Regex
Check password strength requirements in PostgreSQL using regex. SQL examples for enforcing password complexity rules in Postgres.
Mask Credit Card Number in MySQL with REGEXP_REPLACE
Mask credit card numbers in MySQL columns using REGEXP_REPLACE for PCI DSS compliance. SQL examples for credit card data masking.
Validate Credit Card Number Format in PostgreSQL
Use PostgreSQL regex to validate credit card number formats. SQL examples for Visa, Mastercard, and Amex format validation.
Validate SSN Format in MySQL with REGEXP
Use MySQL REGEXP to validate US Social Security Number format XXX-XX-XXXX. SQL examples for SSN format checking and auditing.
Validate US ZIP Code Format in MySQL with REGEXP
Use MySQL REGEXP to validate 5-digit and ZIP+4 US postal codes. SQL query examples for ZIP code format validation.
Validate Postal Code in PostgreSQL Using Regex
Validate US and international postal codes in PostgreSQL using regex. SQL examples for postal code format checking in Postgres.
Validate ZIP Code in SQLite with REGEXP
Check US ZIP code format in SQLite using the REGEXP operator. Setup and SQL examples for postal code validation in SQLite.
Validate US ZIP Code in SQL Server with LIKE Pattern
Use SQL Server LIKE pattern to validate US ZIP code formats in T-SQL. Examples for ZIP code checking in MSSQL.
Extract Numbers from String Column in MySQL with Regex
Use MySQL REGEXP_REPLACE to extract only numeric characters from mixed text columns. SQL examples for number extraction.
Extract Numbers from Text in PostgreSQL with Regex
Use PostgreSQL regexp_matches to extract numeric values from text columns. SQL examples for number extraction from unstructured data.
Find Rows with Numbers Only in MySQL Column with REGEXP
Use MySQL REGEXP to filter rows where a column contains only numeric digits. SQL examples for numeric-only string detection.
Check Alphanumeric String in PostgreSQL Using Regex
Validate that a column contains only alphanumeric characters in PostgreSQL using regex. SQL examples for alphanumeric checks.
Extract File Extension from Filename in MySQL with Regex
Use MySQL REGEXP_SUBSTR to extract file extensions from filename columns. SQL examples for file type extraction and filtering.
Extract File Extension from Path in PostgreSQL with Regex
Use PostgreSQL regexp_matches to extract file extensions from file path columns. SQL examples for file type analysis.
Validate Hex Color Code in MySQL with REGEXP
Use MySQL REGEXP to validate 3 and 6-digit hex color codes in your database. SQL examples for CSS color code validation.
Validate Hex Color Code in PostgreSQL Using Regex
Check hex color code format in PostgreSQL using regex operators. SQL examples for validating CSS color values in a database.
Extract Hashtags from Text Column in MySQL with Regex
Use MySQL REGEXP to find and extract hashtags from social media text stored in database. SQL regex hashtag extraction examples.
Extract @Mentions from PostgreSQL Text Column with Regex
Use PostgreSQL regexp_matches to extract @username mentions from text columns. SQL examples for social media data analysis.
Find Special Characters in MySQL Column with REGEXP
Detect rows with special characters in MySQL using REGEXP. SQL queries to find and clean columns with non-standard characters.
Find Non-ASCII Characters in PostgreSQL Column with Regex
Detect non-ASCII and special characters in PostgreSQL text columns using regex. SQL examples for finding encoding issues.
Extract First and Last Name from Full Name in MySQL
Use MySQL string functions and REGEXP to split full name columns into first and last name parts. SQL examples for name parsing.
Split Full Name into Parts in PostgreSQL with Regex
Use PostgreSQL regexp_split_to_array to split full names into first, middle, and last name parts. SQL examples included.
Validate URL Slug Format in MySQL with REGEXP
Use MySQL REGEXP to validate URL slug format: lowercase letters, numbers, and hyphens only. SQL examples for slug validation.
Validate URL Slug in PostgreSQL Using Regex
Use PostgreSQL regex to validate URL slug format in database columns. SQL examples for permalink and slug validation.
Extract Text Between Brackets in MySQL with Regex
Use MySQL REGEXP_SUBSTR to extract text contained within square or round brackets. SQL examples for bracket content extraction.
Extract Values from JSON-like Text in PostgreSQL with Regex
Use PostgreSQL regexp_matches to extract key-value pairs from JSON-like text strings. SQL examples for text data extraction.
Validate UUID Format in MySQL with REGEXP
Use MySQL REGEXP to validate UUID (Universally Unique Identifier) format in database columns. SQL UUID validation examples.
Validate UUID Format in PostgreSQL Using Regex
Use PostgreSQL regex to validate UUID format in database columns. SQL examples for UUID string validation in Postgres.
Find Empty or Whitespace-Only Values in MySQL with REGEXP
Detect NULL, empty, and whitespace-only string values in MySQL columns using REGEXP. SQL cleanup and audit query examples.
Find Empty Strings and Whitespace in PostgreSQL Using Regex
Use PostgreSQL regex to identify empty, whitespace, and NULL string values in text columns. SQL data quality check examples.
Extract Area Code from Phone Number in MySQL with Regex
Use MySQL REGEXP_SUBSTR to extract the area code from US phone numbers. SQL examples for area code extraction.
Validate MAC Address Format in PostgreSQL with Regex
Use PostgreSQL regex to validate MAC address format in network device tables. SQL examples for MAC address validation.
Validate MAC Address Format in MySQL with REGEXP
Use MySQL REGEXP to validate MAC address format in network-related tables. SQL examples for MAC address checking.
Validate URL Format in SQLite Using REGEXP
Validate URL format in SQLite using the custom REGEXP operator. Setup and SQL examples for URL validation in SQLite.
Find Rows Starting with a Number in MySQL with REGEXP
Use MySQL REGEXP to find rows where a text column starts with a numeric digit. SQL examples for pattern-based filtering.
Extract Year and Month from Date String in PostgreSQL
Use PostgreSQL regexp_matches to extract year and month components from date strings. SQL examples for date parsing.