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

136
Vistas
Regex test causes 'Too much recursion' error in Javascript

I've been implementing validations for the input using Javascript and Regex. I found interesting (at least I think so) behavior with one particular Regex.

/([a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi

This Regex is for the URL input value validation.

Validation is triggered on user input event with some timeout like that:

<input onInput={(event) => this.inputChangedHandler(event)}} />

And the validation part:

...

if (!this.urlPattern.test(this.inputValue)) { // Here I am testing URL regex mentioned above
      this.isValid = false;
      this.validationErrorMessage = 'Please, check URL';
}

...

And in that step I am getting 'Too much recursion error'. In Chrome and Firefox. All other regexes I used in a same way to validate other input types (like email, number, etc etc) working perfectly well.

So my questions are:

Is that behavior expected for large regexes ? Is my regex wrong in some way ?

I have tried this regex to match the string value like this:

this.inputValue.match(this.urlPattern)

Which worked for me well too.

I found some bug report here: bugzilla

Large number of groups in regex causes too-much-recursion crash (YARR)

Seems like really similar to my issue.

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