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

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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