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

180
Vistas
\r\n not splitting string in javascript

I have a string which is multiline. I update this on SFL case object field. When i extract the same from database using SOQL, it appends \r\n\r\n whenever multiline text is found. I tried using different regex expressions with split(\r\n) or split(\r\n) and some more as suggested in different articles, but none of them are helping.

split(\r\n) it removes \r\n from my string but replaces it with ,,

What approach should i take.

SFL input--> This is line 1
             This is line 2

Output--> This is line 1 \r\n\r\n  This is line 2
when using split output--> This is line 1 ,,This is line 2

expected-->
This is line 1
This is line 2

Please help.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Is it possible to split by '\nand then.trim()` each string?

Or you can try this:

var str = `hello
world

ok`;
var arr = str.split(/\r?\n/)
console.log(arr)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use a character set in the regular expression separator.

const string = 'This is line 1\r\n\r\nThis is line 2'
const result = string.split(/[\r\n]+/)
console.log(result)

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