Sign in Start free

Code & Data patterns

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.

8 patterns

CSV fields (quoted values)

(?:^|,)(?:"((?:[^"]|"")*)"|([^,]*))

Splits one CSV line into fields, handling quoted fields with commas and doubled quotes. Group 1 = quoted content, group 2 = plain field.

Code & Data JavaScript /g 1 views ▲ 0

.env / properties lines

^\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.

Code & Data JavaScript /gm 1 views ▲ 0

camelCase to snake_case (replace)

([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.

Code & Data JavaScript /g 1 views ▲ 0

Hexadecimal literal

\b0[xX][\da-fA-F]+\b

0x-prefixed hexadecimal numbers like 0xFF and 0x1a2b.

Code & Data JavaScript /g 1 views ▲ 0

JavaScript / Java / C comments

\/\/.*|\/\*[\s\S]*?\*\/

Line comments (// …) and block comments (/* … */, across lines).

Code & Data JavaScript /g 1 views ▲ 0

JSON / JavaScript string literal

"((?:[^"\\]|\\.)*)"

Double-quoted strings with escaped characters inside (\" \\ \n …). Group 1 is the content.

Code & Data JavaScript /g 1 views ▲ 0

Semantic version

\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).

Code & Data JavaScript /g 1 views ▲ 0

UUID / GUID

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

Code & Data JavaScript /g 1 views ▲ 0