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

202
Visualizações
Javascript: Making A Regular Expression Return All Possible Matches

I'm trying to get all possible matches from a string using regular expression, basically prevent the regex from consuming the characters found in previous match. Example:

'aaaa'.match(/(\w).?\1/g)

would return an array similar to this

result = ['aa', 'aaa', 'aa', 'aaa', 'aa']

where:

result[0] = the first two letters,
result[1] = the first three letter,
result[2] = the second and the third letter, ....

PS: please pardon any misused terms as I'm new to regex.

The match() function used for simplicity, in reality I want to use matchAll() so I can get the match index along with each match.

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