1. 程式人生 > >js 去除空格 回車換行

js 去除空格 回車換行

post rtrim( gpo function log [ ] 左右 去除 return

tempc = tempc.replace(/\ +/g, "");//去掉空格
tempc = tempc.replace(/[ ]/g, "");    //去掉空格
tempc = tempc.replace(/[\r\n]/g, "");//去掉回車換行

//刪除左右兩端的空格
        function trim(str) {
            return str.replace(/(^\s*)|(\s*$)/g, "");
        };

        //刪除左邊的空格
        function ltrim(str) {
            return str.replace(/(^\s*)/g, ""
); }; //刪除右邊的空格 function rtrim(str) { return str.replace(/(\s*$)/g, ""); };

js 去除空格 回車換行