javscript 去除文字换行符

    function transferString(content) {  
        var string = content;  
        try{  
            string=string.replace(/\r\n/g," ")  
            string=string.replace(/\n/g," ");  
        }catch(e) {  
            alert(e.message);  
        }  
        return string;  
    }

  var str =
transferString('sdfafda↵dfafafdsaf');

   console.log(str);

 

 

posted @ 2017-12-16 13:52  Undefined_hui  阅读(147)  评论(0编辑  收藏  举报