zoukankan      html  css  js  c++  java
  • js简单函数封装

    //每index个字符插入一个str字符串

    String.prototype.insertStrPerIndex =function(index,str){
    
    if(this.length>index&&index>0){
    var arr = new Array();
    var num = parseInt(this.length/index);
    console.log(num);
    for(var i=0;i<=num;i++){
    var firstval =i*index;
    if(firstval<this.length){
    arr.push(this.substr(firstval,index));
    }
    }
    return arr.join(str);
    }else{
    return this.toString();
    }
    }

    //去掉字符串两端的空白

    String.prototype.trim = function() {
    return this.replace(/(^s+)|(s+$)/g, "");
    }

    //构建Stringbuffer

    function StringBuffer(){ 
    this.content = new Array; 
    } 
    StringBuffer.prototype.append = function( str ){ 
    this.content.push( str ); 
    } 
    StringBuffer.prototype.toString = function(){ 
    return this.content.join(""); 
    }

     //去掉所有的空格、table

    String.prototype.trimAll = function() {
        return this.replace(/s/g,"")
    }

     //重写replaceAll

    String.prototype.replaceAll =function(oldWord,newWord){
            var res =this;
        var mid ="";
            while((mid=res.replace(oldWord,newWord))!=res){
                res =mid;
            }
            return res;
        }

     //判断是否是中文

    
    
     function ischinese(s){
    
    
                  var ret=true;
    
    
                  for(var i=0;i<s.length;i++)
    
    
                  ret=ret && (s.charCodeAt(i)>=10000);
    
    
                  return ret;
    
    
              }
     
  • 相关阅读:
    AutoResetEvent 2
    AutoResetEvent
    c++ 控制台输入参数
    C# .Net 多进程同步 通信 共享内存 内存映射文件 Memory Mapped
    filezilla管理网站服务器
    matlab
    WCF:无法满足对安全令牌的请求,因为身份验证失败。
    WCF 学习
    dev
    dotnetbar
  • 原文地址:https://www.cnblogs.com/hy928302776/p/6955441.html
Copyright © 2011-2022 走看看