Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!