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

184
Vistas
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
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