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

311
Visualizações
How to remove backslash in a string in React?

I'm very new to React. I'm trying to remove backslash from a string.

[

  {

    "Roll no": 33,
    "Name" : "<p class=\"nameclass\"> \n Rakesh </p>";
 }

]

I want to remove slash in a class and and output will be

<p class="nameclass">Rakesh</p>

Thanks

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You can simply use replaceAll :

string_with_backslash.replaceAll('\\','')

This will remove backslashes except for the new line slash(\n).

about 4 years ago · Juan Pablo Isaza Relatório

0

EDIT: ignore this. The correct answer is provided in the comment by @T.J. Crowder.

It appears you're receiving JSON data via an API. The data will arrive as a STRING and you can parse it to get an OBJECT.

const myJSONData = JSON.parse(response.data)

Can you find out how the server "encodes" the data being sent to you? Understanding what is done in that step is critical to being able to "decode" the data back to the original state. The server is probably stringifying the entire structure, but they may be calling encodeURIComponent or doing other processing that you need to be aware of.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use regular expression and replace to remove the backlash and \n from your string.

use the following code :

let a = "<p class=\"nameclass\"> \n Rakesh </p>";
let n = a.replace(/\n/,"")

output : '<p class="nameclass">  Rakesh </p>'

replace will not do changes in the original string, so store the value in a different string.

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