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

172
Vistas
string replacement with regex

I have field in sql db contains the formula of dynamic calculated question here in my example I have the following string (q1)+(q2).

How can I replace q1 and q2 ... qn , to this eval($(q1).val())+eval($(q2).val())

I need code in c# or javascript to do that .

this is my c# code do replacement (q1),(q2),..(qn) with eval($(q1).val()) , but i need to get q dynamically

`string _equation = dr["calc_equation"].ToString();
 _equation = Regex.Replace(_equation, @"[(]q[0-9][)]+", "eval($(q1).val())");`
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For example:

const f = '(q1)+(q2)';

console.log(f.replace(/\([a-z]\d\)/g,  'eval($$$&.val())'));

Thr first $ escapes the second $, and the $& represents each match.

If there can be more then one letter then use [a-z]+.

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