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

150
Vistas
regex capturing multiple group after a specific string

I want to capture all variable names after "define" keyword (im using js).

I already tried this:

(?<=define\s)(?:([a-zA-Z_]\w*),?\s?)+

but it only captures last occurrence, but i want to get all of them. example string :

define x, y, z, a

link here regex101

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you are using a browser that supports an infinite quantifier in the lookbehind assertion:

(?<=define\s[\w,\s]*)[a-zA-Z_]\w*

The pattern matches:

  • (?<= Positive lookbehind, assert what is at the left is
    • define\s Match define followed by a whitspace char
    • [\w,\s]* Match optional allowed chars in between
  • ) Close lookbehind
  • [a-zA-Z_]\w* Match a single char a-zA-Z or _ and optional word chars

Regex demo

const s = "define x, y, z, a";
const regex = /(?<=define\s[\w,\s]*)[a-zA-Z_]\w*/g;
console.log(s.match(regex));

about 4 years ago · Juan Pablo Isaza 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