EasyRegex Logo
EasyRegex
Neu

Match Hex Color Value

Javascript

Regulärer Ausdruck

#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Kopieren
Haben Sie Feedback?

Erklärung

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

Beispielverwendung

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

Ähnliche Reguläre Ausdrücke