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

182
Views
How to capture a dynamic regex pattern in javascript?

In javascript regex, I have the following capture pattern, see regexCapture:

rsqlFilter = "(testId==\"*abcd*\",tenantName==\"*abcd*\",applicationName==\"*abcd*\",projectName==\"*abcd*\")";
let regexCapture = /testId=="\*(.+?)\*"/;
let matchx = rsqlFilter.match(regexCapture);
console.log(matchx[1]);  // it's the string abcd

Now, I want that columnName testId to be dynamic, a variable, instead of hard coded text. How do I do that as the following code below will fail to capture?

rsqlFilter = "(testId==\"*abcd*\",tenantName==\"*abcd*\",applicationName==\"*abcd*\",projectName==\"*abcd*\")";
let columnName = 'testId';
let regexCapture = `/${columnName}=="\*(.+?)\*"/`;
let matchx = rsqlFilter.match(regexCapture);
console.log(matchx[1]);  // -----------> WILL FAIL!
about 4 years ago · Juan Pablo Isaza
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!