姿姿霸霸~~!
          貴在堅持!
          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  回復  更多評論
            

          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          好友的blog

          搜索

          •  

          積分與排名

          • 積分 - 118088
          • 排名 - 499

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 英德市| 瑞丽市| 广平县| 治多县| 天祝| 攀枝花市| 盐池县| 岳阳县| 大姚县| 龙海市| 高碑店市| 泸州市| 乌海市| 淮北市| 凤冈县| 尉犁县| 河曲县| 磴口县| 阳江市| 阳谷县| 泉州市| 乌拉特后旗| 福泉市| 栾川县| 洪江市| 阳谷县| 鄂托克前旗| 娱乐| 民权县| 玛多县| 定西市| 吉首市| 岳普湖县| 綦江县| 通榆县| 六枝特区| 长兴县| 海阳市| 多伦县| 甘南县| 桐梓县|