Valid RGB color value

Published on Tue Mar 01 2022

Pattern for matching actually valid RGB values. - validate separator (mixing spaces and commas between values is not valid) - validate if comma is used as separator if alpha channel is set - validate units (mixing percentage with integers is not valid) - extract `r`, `g`, `b`, `a`, `separator` and `unit` with named groups

Additional matching regexes for
Valid RGB color value

Valid RGB color value

Pattern for matching actually valid RGB values. - validate separator (mixing spaces and commas between values is not valid) - validate if comma is used as separator if alpha channel is set - validate units (mixing percentage with integers is not valid) - extract `r`, `g`, `b`, `a`, `separator` and `unit` with named groups

iOS Localizable.strings parser

Can be used to find all keys and values in .strings file. Matching pattern: "key" = "value";

html color match: transparent, #fff, #123456, rgb, rgba, hsl, hsla

This may be useful or not to test whether a given string is a valid (more or less) html color value. It matches color values such as: - #123 - short hex color value - #123456 - hex color value - rgb(255,255,0) - rgb color value - rgba(255,255,0,1.0) - rgba color value - hsl(360,100%,100%) - hsl color value - hsla(360,100%,100%,0.5334) - hsla color value Regex allows whitespaces between i.e. rgb and (, also between numbers and commas, but not in value like 55% between number and percentage. To change this behaviour simply remove \s*? from appriopriate places.

matching value of html src attribute

matching value of html src attribute

Color RegEx

Color RegEx

CFF-definitions.reference.isbn

Pattern for validating a `definitions.reference.isbn` value in the Citation File Format (CFF)

what3words

This pattern check three words with a dot separator betwwern words. It use unicode; It is not yest compatible with javascript

CSS Colors: RGB(A), HSL(A), HEX(3,4,6,8), var(--tw-color), etc...

Versatile, multiline matching of CSS colors of many common formats, including: - [x] HEX-3: `#123` (equivalent to `#112233`) - [x] HEX-4: `#FA0F` ( ... `#FFAA00FF`) - [x] HEX-6: `#FF3300` ( ...`#F30`) - [x] HEX-8: `#FFAA00FF` ( ...`#FA0F`) - [x] RGB: `rgb(0, 0, 0)` - [x] RGBA: `rgba(255, 255, 255, 1.0)` - [x] HSL: `hsl(100, 50%, 50%)` - [x] HSLA: `hsla(100, 20%, 20%, 1.0)` - [x] Vars: `var(--tw-color-name, #000000)` - [x] Misc: `color: inherit;` `color: currentColor;` `color: initial;`, etc. * With or without trailing semicolon or comma * Forgiving of whitespace issues * Allows property/declaration names (e.g. `color: #fff`), most other solutions do not.

parsing CSV file

It correctly handles simple values, empty values, and quoted values with commas inside.

Regex to match any JSON value with fewer steps possible

If you find... - any JSON value that should be matched but isn't, - any JSON value that should NOT be matched but is - or simply a way to match the values with fewer steps... please, let me know.