EasyRegex Logo
EasyRegex
Nuevo

Match Hex Color Value

Javascript

Expresión Regular

#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Copiar
¿Tienes Comentarios?

Explicación

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

Ejemplo de Uso

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

Expresiones Regulares Similares