function regDir(str){
    var reg=str
    if(typeof reg=="string"){
        reg=reg.replace(/[\[\]\\\^\:\.\?\+]/g,function(m){
            return "\\"+m;
        })
        reg=reg.replace(/\*\*|\*/g,function(m){
            if(m=="**"){
                return "[\\w\\W]*";
            }else{
                return "[^\\\/]*";
            }

        })
        reg=new RegExp(reg,"gi")
    }
    return reg
}
String.prototype.Test=function(regStr){
    var reg=regDir(regStr)
    return reg.test(this)
}
String.prototype.Replace=function(regStr,fn){
    var reg=regDir(regStr)
    return this.replace(reg,fn);
}
//是否符合
var str="http://www.baidu.com/b/da.js?n=21"
str=str.Replace("(http://**/*)?*",function(m,p1,p2){
    console.log(p1)
    return p1
})
str.Replace("http:/(/**/)*",function(m,p1,p2){
    console.log(p1)
})

  

相关文章:

  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
相关资源
相似解决方案