姿姿霸霸~~!
          貴在堅持!
          posts - 106,  comments - 50,  trackbacks - 0
          1.String.prototype.Trim = function()
          {
              return this.replace(/(^\s*)|(\s*$)/g, "");
          }
          String.prototype.LTrim = function()
          {
              return this.replace(/(^\s*)/g, "");
          }
          String.prototype.Rtrim = function()
          {
              return this.replace(/(\s*$)/g, "");
          }

          2.全文匹配替換
          var regExp = new RegExp("需要被替換的字符',"g")
          var text = "…………";
          text = text.replace(regExp , "替換的字符");

          3.方案
          String .prototype.trim = function(){
             var matches = this.match(/^[ \t\n\r]+/);
             var prefixLength = (matches == null) ? 0:matches[0].length;
             matches = this.match(/[ \t\r\n]+$/);
             var suffixLength = (matches == null) ? 0:matches[0].length;
             return this.slice(prefixLength,this.length-suffixLength);
          }
          posted on 2008-08-27 16:12 xrzp 閱讀(8989) 評論(2)  編輯  收藏 所屬分類: js

          FeedBack:
          # re: 去除空格的js 和 使用正則表達式替換[未登錄]
          2010-08-18 10:46 | 123
          123 123 123 123 123 123  回復  更多評論
            
          # re: 去除空格的js 和 使用正則表達式替換
          2013-08-28 15:13 | fff fddd
          dfasfdsa  回復  更多評論
            

          <2013年8月>
          28293031123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          好友的blog

          搜索

          •  

          積分與排名

          • 積分 - 118111
          • 排名 - 499

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 静乐县| 东莞市| 什邡市| 子长县| 会东县| 通河县| 英吉沙县| 光泽县| 金川县| 台东市| 绥化市| 兖州市| 雷波县| 乌兰县| 时尚| 滦南县| 敖汉旗| 武安市| 都安| 仁寿县| 茶陵县| 延吉市| 和田市| 饶平县| 长葛市| 吕梁市| 平安县| 平舆县| 澳门| 藁城市| 唐海县| 百色市| 罗源县| 疏附县| 安义县| 长寿区| 武川县| 衢州市| 武隆县| 麟游县| 布尔津县|