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

112
Visualizações
characters missing in javascript replace function vuejs

I am using the replace method as follows:

<code v-html="'/<test>/'.replace(/(?:\r\n|\r|\n)/g, 'testing')"></code>

I have a larger string that I am testing against with many \n but I noticed with the above replace function to remove these characters, somehow the value <test> inside // gets replaced.

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

0

The /<test>/ string isn't turning into //, it's being rendered by the v-html directive. To more accurately test your replace method I'd recommend using the v-text directive instead.

Below is a demonstration of the difference in output between the two directives.

new Vue({
  el:"#app"
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <p>Using v-html</p>
  <code v-html="'/<test>/'.replace(/(?:\r\n|\r|\n)/g, 'testing')"></code>
  <br/>
  <p>Using v-text</p>
  <code v-text="'/<test>/'.replace(/(?:\r\n|\r|\n)/g, 'testing')"></code>
</div>

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