Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!