Tested regular expressions you can open in the tester, read the explanation of and adapt. Each pattern comes with sample text and unit tests. Save your own pattern with Save & share and tick “publish” to add it here.
52 patterns
{2,}
Finds two or more spaces in a row; replace with a single space.
(?:^|,)(?:"((?:[^"]|"")*)"|([^,]*))
Splits one CSV line into fields, handling quoted fields with commas and doubled quotes. Group 1 = quoted content, group 2 = plain field.
^\s*([A-Za-z_][\w.]*)\s*=\s*"?([^"\n]*)"?\s*$
KEY=value lines; group 1 is the key, group 2 the value (quotes not included). Comments and blank lines are skipped.
([a-z\d])([A-Z])
Inserts an underscore before each capital letter that follows a lowercase letter or digit. Replace with "$1_$2" and lowercase the result in code.
\b0[xX][\da-fA-F]+\b
0x-prefixed hexadecimal numbers like 0xFF and 0x1a2b.
\/\/.*|\/\*[\s\S]*?\*\/
Line comments (// …) and block comments (/* … */, across lines).
"((?:[^"\\]|\\.)*)"
Double-quoted strings with escaped characters inside (\" \\ \n …). Group 1 is the content.
\bv?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?(?:\+([\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*))?\b
MAJOR.MINOR.PATCH with optional pre-release and build metadata, from the semver.org specification (simplified).
\b[\da-fA-F]{8}-[\da-fA-F]{4}-[1-8][\da-fA-F]{3}-[89abAB][\da-fA-F]{3}-[\da-fA-F]{12}\b
Version 1–8 UUIDs in the canonical 8-4-4-4-12 form, any case.
(?:\+1[ .-]?)?\(?([2-9]\d{2})\)?[ .-]?(\d{3})[ .-]?(\d{4})\b
(415) 555-2671, 415-555-2671, 415.555.2671 and +1 415 555 2671.
^\+[1-9]\d{6,14}$
A plus sign followed by up to 15 digits, the format used by most SMS and telephony APIs.
^[A-Za-z][\w.]{1,14}[A-Za-z\d_]$
3 to 16 characters: letters, digits, underscores and dots; must start with a letter and cannot end with a dot.
\b(?:4\d{3}|5[1-5]\d{2}|2[2-7]\d{2})(?:[ -]?\d{4}){3}\b|\b3[47]\d{2}[ -]?\d{6}[ -]?\d{5}\b
Visa, Mastercard and American Express number formats with optional spaces or dashes. Checks the shape only – use the Luhn checksum in code.
\b(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?)%
Numbers from 0 to 100 followed by a percent sign, decimals allowed.
\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?\b
$5, $1,000, $12.99 – optional thousands separators and cents.
\B(?=(\d{3})+(?!\d))
Substitution trick: inserts a comma before every group of three digits that is followed only by more groups of three. Use the Substitution function with replacement ",".
\b\d{1,3}(?:,\d{3})*(?:\.\d+)?\b
1,234,567.89 style numbers: groups of three digits separated by commas, optional decimals.
[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?
Numbers with optional sign, decimals and exponent, like 3.14, -0.5, .5 and 6.02e23.
^[+-]?(0|[1-9]\d*)$
Whole numbers with an optional sign, no leading zeros.
\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?
2026-11-12T08:30:00Z style timestamps with optional fraction and time zone offset.
\b(1[0-2]|0?[1-9]):([0-5]\d)\s?([AaPp][Mm])\b
1:00 to 12:59 followed by am/pm in any case, with or without a space.
\b([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?\b
Times from 00:00 to 23:59 with optional seconds.
\b(0?[1-9]|[12]\d|3[01])([/.-])(0?[1-9]|1[0-2])\2(\d{4})\b
Day/month/year dates with / . or - separators (the same separator twice, checked with a back reference).
[?&]([^=&#]+)=([^&#]*)
Splits a URL query string into name (group 1) and value (group 2) pairs.