SQL Patterns Library

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.

MySQL · 39PostgreSQL · 34SQLite · 6mssql · 6
🤖 Generate Custom SQL — Free
MySQLdata extraction

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.

PostgreSQLdata validation

Validate Email Address in PostgreSQL with Regex

Use PostgreSQL ~ operator to validate email addresses. SQL examples for email validation with regex in Postgres databases.

SQLitedata validation

Validate Email in SQLite Using REGEXP

Validate email addresses in SQLite using the REGEXP operator. Setup instructions and SQL examples for email format checking.

mssqldata validation

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.

MySQLdata extraction

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.

MySQLdata 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.

MySQLduplicate detection

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.

PostgreSQLdata extraction

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.

MySQLdata validation

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.

PostgreSQLdata extraction

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.

PostgreSQLstring matching

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.

SQLitedata validation

Validate Phone Number in SQLite Using REGEXP

Validate phone number formats in SQLite using custom REGEXP function. Setup and SQL examples for phone validation.

mssqldata 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.

PostgreSQLdata validation

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.

MySQLdata 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.

MySQLduplicate detection

Deduplicate Phone Records by Normalizing Format in MySQL

Normalize phone number formats using REGEXP_REPLACE in MySQL then deduplicate. SQL examples for phone deduplication.

MySQLdata validation

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.

PostgreSQLdata extraction

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.

mssqldata validation

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.

MySQLdata extraction

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.

PostgreSQLdata extraction

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.

MySQLdata validation

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.

MySQLdata validation

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.

PostgreSQLdata 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.

MySQLdata extraction

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.

PostgreSQLdata 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.

MySQLdata validation

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.

mssqldata validation

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.

MySQLdata validation

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.

PostgreSQLdata validation

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.

MySQLdata validation

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.

PostgreSQLdata validation

Validate IPv6 Address in PostgreSQL Using Regex

Validate IPv6 address format in PostgreSQL using regex operators. SQL examples for IPv6 address validation in Postgres.

SQLitedata validation

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.

MySQLdata validation

Validate Username Format in MySQL with REGEXP

Use MySQL REGEXP to validate usernames with alphanumeric and underscore characters. SQL examples for username enforcement.

PostgreSQLdata validation

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.

MySQLdata validation

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.

MySQLdata extraction

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.

PostgreSQLdata 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.

MySQLdata validation

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.

PostgreSQLdata validation

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.

PostgreSQLduplicate detection

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.

PostgreSQLduplicate detection

Find Duplicate Emails in PostgreSQL with Regex Validation

Detect duplicate valid email addresses in PostgreSQL using GROUP BY with regex filtering. SQL deduplication examples.

mssqlduplicate detection

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.

SQLiteduplicate detection

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.

MySQLdata extraction

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.

PostgreSQLdata extraction

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.

MySQLstring matching

Remove Extra Whitespace from MySQL Column with REGEXP_REPLACE

Use MySQL REGEXP_REPLACE to remove leading, trailing, and multiple consecutive spaces from text columns.

PostgreSQLstring matching

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.

MySQLdata validation

Check Password Strength in MySQL with REGEXP

Use MySQL REGEXP to validate password complexity: uppercase, lowercase, digits, special characters. SQL audit query examples.

PostgreSQLdata validation

Validate Strong Password in PostgreSQL Using Regex

Check password strength requirements in PostgreSQL using regex. SQL examples for enforcing password complexity rules in Postgres.

MySQLstring matching

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.

PostgreSQLdata validation

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.

MySQLdata 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.

MySQLdata validation

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.

PostgreSQLdata 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.

SQLitedata validation

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.

mssqldata validation

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.

MySQLdata extraction

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.

PostgreSQLdata 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.

MySQLstring matching

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.

PostgreSQLdata validation

Check Alphanumeric String in PostgreSQL Using Regex

Validate that a column contains only alphanumeric characters in PostgreSQL using regex. SQL examples for alphanumeric checks.

MySQLdata extraction

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.

PostgreSQLdata extraction

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.

MySQLdata validation

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.

PostgreSQLdata 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.

MySQLdata extraction

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.

PostgreSQLdata extraction

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.

MySQLstring matching

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.

PostgreSQLstring matching

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.

MySQLdata extraction

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.

PostgreSQLdata extraction

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.

MySQLdata validation

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.

PostgreSQLdata 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.

MySQLdata extraction

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.

PostgreSQLdata 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.

MySQLdata validation

Validate UUID Format in MySQL with REGEXP

Use MySQL REGEXP to validate UUID (Universally Unique Identifier) format in database columns. SQL UUID validation examples.

PostgreSQLdata validation

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.

MySQLdata validation

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.

PostgreSQLdata validation

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.

MySQLdata extraction

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.

PostgreSQLdata validation

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.

MySQLdata 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.

SQLitedata validation

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.

MySQLstring matching

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.

PostgreSQLdata extraction

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.