Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
JavaScript - Regular Expression to Validate Hexidecimal Color

I am trying to create a regular expression in JavaScript to see if a string is a valid hexidecimal color. From my understanding, hexidecimal colors can be 3-6 characters long (if you ignore the leading '#'). Each character must be in the range of A-F, a-f, and 0-9. In an attempt to write this regular expression, I have the following:

let value = 'abcxyz';
let rex = new RegExp('[A-F0-9]{3,6}', 'i');
let result = rex.test(value);
console.log(`value: '${value}' is a hexidecimal color: ${result}`);

Oddly, this prints:

value: 'abcxyz' is a hexidecimal color: true 

I do not see how value can possibly match the regular expression provided. What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda