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

188
Views
Problem Reading File Content into Variable

I'm building a little tool to create a source code file.

The tool iterates through a directory, gets all *.js files and reads them all to an array. For example React (https://unpkg.com/react@18/umd/react.production.min.js).

Reading File > save to variable
Write variable to file > e.g. `const myVariable = `${fileContent}`;`

This alone obviously doesn't work. I have to replace line breaks etc.

e.g:

content.replace(/(?:\r\n|\r|\n)/g, "");

And that's the problem. Replacing special characters results in unexpected behavior (syntax errors of the final JavaScript).

Question: How to replace special characters properly?

about 4 years ago · Juan Pablo Isaza
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!