javascript replace() not replacing text containing literal \r\n strings

后端 未结 3 1765
庸人自扰
庸人自扰 2020-12-29 07:36

Using this bit of code trims out hidden characters like carriage returns and linefeeds with nothing using javascript just fine:

value = value.replace(/[\\r\\         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-29 08:14

    If you have text with a lot of \r\n and want to save all of them try this one

    value.replace(/(?:\\[rn]|[\r\n])/g,"
    ")

    http://jsfiddle.net/57GtJ/63/

提交回复
热议问题