首页 > Web开发 > 详细

js 去除空格 回车换行

时间:2018-03-12 13:05:07      阅读:140      评论:0      收藏:0      [点我收藏+]
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 去除空格 回车换行

原文:https://www.cnblogs.com/caolingyi/p/8548379.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!