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

201
Vistas
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 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