[Vuejs]-How to filter numbers out of an Text

-1👍

You should change this:

returnList: function(value){
  value.replace("\n","<br>")
  return value`
}

to this:

returnList: function(value) {
  value = value.replace("\n","<br>")
  return value;
}

Becuase .replace does not change value itself, but return a new value with the changes.

But, will only change the first value anyway. So you could use this solution value.split("\n").join("<br>").

3👍

Firstly, you should know that String.prototype.replace function returns the result of the replacement.

let obj = {
  "description": "this ist our List.\n Our Service includes:\n-1 something\n-2 something else\n and another thing\n"
};

console.log(obj.description.replace(/\n-[0-9]+/g, "<br>"))

Another regex approach: /\n(-\d)?/g

👤Ele

1👍

You need to use regex. Like that: value.replace(/\/n/g,"<br>")

Leave a comment