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

106
Views
Agregue una cadena usando expresiones regulares al final de los valores de URL dentro del objeto anidado en Node.js

Objeto de muestra (el siguiente objeto es un objeto anidado muy grande):

 const obj = { a: 1, url: "https://someurl.com", b: { c: 1, d: { otherUrl: "https://someotherurl.com"}};

Quiero agregar algún parámetro de consulta al final de cada URL, como ?d=1234 .

Intenté hacerlo, pero las URL están cambiadas:

 const convertedObj = JSON.stringify(obj); let bufferObj; const fullRegex = /url":"([^"]*)/g; const fullMatch = convertedObj.match(fullRegex); if(fullMatch) { fullMatch.forEach((str, i) => { bufferObj = convertedObj.replace(/(url|Url)":"([^"]*)/g, `${str}?d=1234`); }); }

¿Hay una solución para esto en Node.js usando expresiones regulares?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let convertedObj = JSON.stringify(obj); const fullRegex = /(url|Url)":"([^"]*)/g; const fullMatch = convertedObj.match(fullRegex); if(fullMatch) { fullMatch.forEach((str, i) => { convertedObj = convertedObj.replace(str, `${str}?d=1234`); }); } console.log(convertedObj);
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!