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

129
Views
how do i remove \n and \r in from aReadStream text file

so i need to get from a text file alot of data and when i use fs.createReadStream and copy the data to a varible and start changing it it looks like \n and \r and present and the are messing my splits and array checking and i tried to do a function that removes them that runs on the array and checks for ''(it doesnt work for some reason)

if(arr[i]==='\'(this throws the mistake){**strong text**
(removing it and stuff)
}

do you have any idea how to remove it?

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

0

You can either use the String prototype replaceAll, or work with split and join:

let data = '\r \n sdfsdf. \r'

data = data.replaceAll(`\r`, '')
data = data.replaceAll(`\n`, '')



OR ------------------------

let data = '\r \n sdfsdf. \r'

data = data.split(`\r`).join('').split(`\n`).join()


Pay attention - replaceAll is a new prototype and exists only on Node v.15+ and the latest versions of the modern browsers. See MDN documents to check your needs.

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!