Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda