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

125
Views
Reemplace un \n en objetos, que están en una matriz

Quiero reemplazar \n que está en una matriz de objetos. Por ahora encontré esto, pero reemplaza solo una cadena, no un '\ n' real que hace que la línea se rompa.

 var obj = { 'a': '\nThe fooman poured the drinks.', 'b': { 'c': 'Dogs say fook, but what does the fox say?' } } console.log(JSON.parse(JSON.stringify(obj).replace(/\n/g, '')));

Gracias a todos

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

0

Deberías usar \\n en regax.

 var obj = { 'a' : '\nThe fooman poured the drinks.', 'b' : { 'c' : 'Dogs say fook, but what does the fox say?' } } console.log (JSON.parse(JSON.stringify(obj).replace(/\\n/g, '')));

about 4 years ago · Juan Pablo Isaza Report

0

Debe agregar otra barra invertida ( \\ ) para seleccionar la primera

 console.log (JSON.parse(JSON.stringify(obj).replace(/\\n/g, '')));
about 4 years ago · Juan Pablo Isaza Report

0

Debe escapar de la barra invertida de escape para tratarlo como una barra invertida literal.

Regex: /\\n/g

 var obj = { 'a': '\nThe fooman poured the drinks.', 'b': { 'c': 'Dogs say fook, but what does the fox say?' } } console.log(JSON.parse(JSON.stringify(obj).replace(/\\n/g, '')));

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!