InRegex Logo
InRegex

Match Hex Color Value

Explication

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

Expression Régulière

#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Copier
Avez-vous des Retours ?
Javascript

Exemple d'Utilisation

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

Testez l'expression

Expressions Régulières Similaires