InRegex Logo
InRegex
Nuovo

Match Hex Color Value

Spiegazione

This regex pattern matches a hex color value that starts with a '#' followed by either 3 or 6 characters that can be any combination of letters A-F (uppercase or lowercase) and numbers 0-9.

Javascript

Espressione Regolare

#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Copia
Javascript

Esempio di Utilizzo

const regex = /#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/; 
const color = '#1a2B3c'; 
console.log(color.match(regex));
Copia

Prova l'espressione

Espressioni Regolari Simili