Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda