I am trying to replace the \n or \r to an empty spaces which comes with some other additional word. But when I tried it never replace the value because it understand it as a new line. For example this is the sample string str = "i need help \n"
I even tried using string.replace(/\r?\n|\r/g, " ") but it didn't work for me.
service.add = function(req) {
var str= req.inputFromUI;
if(str.indexOf("\n") > -1) {
req.inputFromUI= str.replace("\n", " ");
}
}
Note:
I will always have \n or \r from the test box and the requirement is something I can't restrict \n or \r in the UI. If I tried with the normal letter or word it worked for me. But the issue is only with the \n. I use my whole day to fix it but couldn't able to fix it. Can anyone help me to fix it PLEASE!! Thank you in advance. FYI: I am using angularjs.