Tagged Fiddles
- 1RevisionsForks
[Validate] CSS Color
/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))$/gi#+ These are all valid CSS colors rgb(255, 255, 255) rgba(255, 255, 255, 0) rgba(255, 255, 255, 0%) hsl(50, 150, 100) hsla(50, 150, 100, 0) hsla(50, 150, 100, 0%) - 1RevisionsForks
Hex color codes
/^#([0-9A-F]{3}){1,2}$/iDemonstrates how regex corpus unit tests work.#+ The following lines will be tested. If they match, they'll be hilighted in green, otherwise they'll be red #1f1f1F #AFAFAF #1AFFa1 #222fff #F00 #- Nothing below this line should match, if it does it'll show up red 123456 #afafah #123abce aFaE3f F00#afaf #F0h