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

78
Vistas
Create array of regex matches javascript

I want to create an array of matches for my regex expression in javascript.

It should look like: ['<:S_egirl:1023714296590499882>', '<a:eee:1023672889490284606>'] However, my code currently only makes an array with 1 item which includes all the matches.

The expression is: /<:.+:(\d+)>/gm

And my code is const parsed_emotes = [].concat(emotes.match(/<:.+:(\d+)>/gm)); console.log(parsed_emotes);

I've been stuck on this for hours, any help is appreciated.

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

0

Make your .+ non-greedy with ?. Compare the output of these two matches:

'<:hello:1234> <:hello:1234>'.match(/<:.+:(\d+)>/gm)
// Produces ['<:hello:1234> <:hello:1234>']

Vs a non-greedy match:

'<:hello:1234> <:hello:1234>'.match(/<:.+?:(\d+)>/gm)
// Produces ['<:hello:1234>', '<:hello:1234>']
almost 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