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

246
Vistas
Regex for alphanumeric characters but all of which are not zero

Conditions:-

  1. Total length = 12
  2. First letter = A
  3. Second letter = B
  4. Rest of the 10 characters = Numbers or alphabets
  5. Rest of the 10 characters cannot be equal to 0000000000

Valid:-

  1. AB1234567890
  2. ABABABABABAB
  3. AB1234HIJ001

Invalid:-

  1. AB0000000000
  2. AB0
  3. AA1234567890

I have come up with this regex: '^[A-A][B-B][A-Z0-9]{10}$'. It prevents Invalid #2 and #3. But I'm having a hard time with Invalid #1. I know that to prevent all characters from being 0, I need to use '^0+$'. But how do I combine these two expressions?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can add a negative lookahead to accomplish this: (?!0{10}).

^[A-A][B-B](?!0{10})[A-Z0-9]{10}$
           ^^^^^^^^^

regex101 demo

By the way, you don't need [A-A][B-B]. Just AB does exactly the same.

about 4 years ago · Juan Pablo Isaza Denunciar
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