Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
\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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda