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

281
Vistas
What would the correct syntax be for this REGEX expression?

I have the following REGEX code, ie:

/^IT [0-9]{1,5}/(?<y1>19)?(?(y1)\d{2}|20\d{2})\((?<n1>M)?(?(n1)N|[H|B|C|D|E|G|K|M|U|N|L|S|T|V])\)$/

It is meant to check a group of words and ensure that it evaluates to:

IT 1/2014(G)

or any value up to 5 digits

IT 5000/2014(MN)

I keep getting the following error when running the above in firefox however:

Uncaught SyntaxError: invalid regexp group

Any help at all wouild be greatly appreciated.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The pattern contains an if clause which is not supported.

(?<y1>19)?(?(y1)\d{2}|20\d{2})

If group y1 exists, match 19 and 2 digits, else match 20 and 2 digits.

That can be written as (?:19|20)\d{2}

The same goes for

(?<n1>M)?(?(n1)N|[H|B|C|D|E|G|K|M|U|N|L|S|T|V])

If group n1 exists, match MN else match one of the listed in the character class.

That can be written as (?:MN|[HB-EGKMUNLSTV])


The whole pattern might look like:

 ^IT [0-9]{1,5}\/(?:19|20)\d{2}\((?:MN|[HB-EGKMUNLSTV])\)

Regex demo

over 4 years ago · Santiago Trujillo 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