﻿function Regular(){
    this.isBlog=function(s){
        var patrn = /^[a-z]([a-z]|[0-9]){4,39}$/;
        if (!patrn.exec(s))
            return false;
        return true;
    }
    this.isEmpty=function(str){
        if (str!=undefined){
            if (str.length>0){return false;}
            else{return true;}
        }else{return true;}
    }
    this.isString=function(s){
        var patrn = /^[a-z]{5,19}$/;
        if (!patrn.exec(s))
            return false;
        return true;
    }
    this.isEmail=function(str){
        if (str=="undefined"||str.length==0){
            return false;
        }else{
            if (str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
                return true;
            }else{
                return false;
            }            
        }
    }
    this.isMobile=function(str){
        if (str.search(/^(13|15|18)[0-9]{9}$/)!=-1){
            return true;
        }else{
            return false;
        }
    }
    this.isZipcode=function(str){
        if (str.search(/^[0-9]{6}/) != -1){
            return true;
        }else{
            return false;
        }
    }
    this.isNumber=function(str){
        if (str.search(/^[0-9]/) != -1){
            return true;
        }else{
            return false;
        }
    }
    this.isBirthday=function(str){
        if (str.search(/^(19[0-9]{2})|200[0-9]-(0[0-9])|(1[1,2])-([0,1,2][0-9])|(0[0,1])$/)!=-1){
            return true;
        }else{
            return false;
        }
    }
}
String.prototype.replaceAll  = function(s1,s2){ 
    return this.replace(new RegExp(s1,"g"),s2);   
  } 
