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

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

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 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!