去掉空格 回车

Jquery:
$("#accuracy").val($("#accuracy").val().replace(/ +/g,""));//去掉空格

.replace(/ +/g,"") //去掉空格方法
$("#content").val($("#content").val().replace(/[ ]/g,""));    //去掉空格

.replace(/[ ]/g,"")//去掉空格
$("#content").val($("#content").val().replace(/[ ]/g,""));//去掉回车换行

.replace(/[ ]/g,"")//去掉回车换行

.replace(/-/g, '') //去掉"-"号

js:

var testStr="sssss

vvvvv";
var resultStr=testStr.replace(/ +/g,"");//去掉空格

resultStr=testStr.replace(/[ ]/g,"");    //去掉空格

resultStr=testStr.replace(/[ ]/g,""));//去掉回车换行

java 返回值为string时,使返回的String中间有换行:
只需要在要换行的地方加上转义字符“ ”即可实现换行。
如:String function(){ return "hello world"; // 返回“hello”换行“world”}

原文地址:https://www.cnblogs.com/wsj1/p/11421826.html