본문 바로가기

개발자공부/기초정리

정규식 정리

 

http://regexr.com/

  


var alphanumeric = /^[a-zA-Z0-9]+$/; // 영어 , 숫자

var alpha = /^[a-zA-Z]+$/; // 영어

var numberic = /^[0-9]+$/; // 숫자

var telnumberic = /^[0-9-]+$/; //전화번호 숫자, -

var hangle = /^[\uAC00-\uD7A3]+$/; // 한글

var engkornum = /^[a-zA-Z0-9\uAC00-\uD7A3\s-_]+$/; // 영어 , 숫자 , 한글 , - , _

var email = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i;

// 이메일

var URL = /(((http|ftp|https):\/\/))[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#!]*[\w\-\@?^=%&/~\+#])?/;

if(hangle.test($('#mberNm').val()) === false) {

alert("이름은 한글만 입력 가능합니다");

$('#mberNm').focus();

return false;

}

 

function checkPassword4 (value) {    

var temp = "";

var intCnt = 0;

for ( var i = 0; i < value.length; i++ ) {

temp = value.charAt(i);

if ( temp == value.charAt(i+1) && temp == value.charAt(i+2) && temp == value.charAt(i+3) && temp == value.charAt(i+4) ) {     

intCnt = intCnt + 1;

}

}

    if(intCnt>0){

        return true;

    }else{

        return false;

    }

}

 

function checkPassword3(value) {

var cnt=0,cnt2=1,cnt3=1;

var temp="";

    var temp_pass1="";

    var next_pass="";

    var temp_p="";

    var temp_pass2="";

 

for(i=0;i < value.length;i++){

temp_pass1 = value.charAt(i);

next_pass = (parseInt(temp_pass1.charCodeAt(0)))+1;

temp_p = value.charAt(i+1);

temp_pass2 = (parseInt(temp_p.charCodeAt(0)));

if (temp_pass2 == next_pass)

cnt2 = cnt2 + 1;

else

cnt2 = 1;

if (temp_pass1 == temp_p)

cnt3 = cnt3 + 1;

else

cnt3 = 1;

if (cnt2 > 3) break;

if (cnt3 > 3) break;

}

if (cnt2 > 3){

    return true;

}

return false;

}

 

 

if(checkPassword3($('#password').val())){

alert("4개이상의 연속된 숫자와 문자는 사용 없습니다.");

$('#password').focus();

return false;

}

if(checkPassword4($('#password').val())){

alert("반복문자나 숫자 연속 4개이상 사용할 없습니다.");

$('#password').focus();

return false;

}