본문 바로가기

프로그래밍

정규식 모음

반응형

 

설명  정규식
인터넷 주소 1. /^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z](\:[0-9]+)?(\/\S*)?/ 
2. (http|https):\/\/((\w+)[.])+
(asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|tw|uk|us)(\/(\w*)).*$
 IP 주소 한 옥탯 주소(255.)
/(\\d|1\\d\\d|2[0-4]\\d|25[0-5])/


모든 옥탯 주소(255.255.255.255)
(\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|1\\d\\d|2[0-4]\\d|25[0-5])
 HTML 태그 태그
 /<(\/)?([a-zA-Z]*)(\s[a-zA-Z]*=[^>]*)?(\s)*(\/)?>/ig

특정 태그 확인
/<\s*\/?\s*(code|em|ul|br)\b.*?>/

개행 문자
/(?:\r\n|\r|\n)/g



html 내 텍스트만 추출
/(<([^>]+)>)/ig


사잇값 추출  ■.*?[\w|\t|\r|\W]*?■
'■안녕■하세요.'  라는 문자열이 있을 때
■로 둘러쌓인 텍스트('안녕')를 추출한다.
 한글,영어,숫자
추출하기
한글 추출 /[^\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F]/gi 
또는 /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/g
영어 추출 /[^a-zA-Z]/g
숫자 추출 /[^0-9]/g
개인정보 1. 주민등록번호
(?<=[^0-9a-zA-Z])([0-9][0-9][01][0-9][0-3][0-9][\s-:\.]?)([1-4]\d{6})(?=[^0-9a-zA-Z])

2. 여권번호
(?<=[^0-9a-zA-Z])([M|S|R|O|D|m|s|r|o|d][0-9]{8})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])([a-zA-Z]{2}[0-9]{7})(?=[^0-9a-zA-Z])

3. 운전면허번호
(?<=[^0-9a-zA-Z])(\d{2}[\s-:\.])(\d{6}[\s-:\.])(\d{2})(?=[^0-9a-zA-Z])

4. 핸드폰번호
(?<=[^0-9a-zA-Z])(01[0|1|6|7|8|9][\s-:\.]?)(\d{3,4}[\s-:\.]?)(\d{4})(?=[^0-9a-zA-Z])

5. 신용카드번호
(?<=[^0-9a-zA-Z])(\d{4}[\s-:\.])(\d{4}[\s-:\.])(\d{4}[\s-:\.])(\d{4})(?=[^0-9a-zA-Z])

6. 건강보험번호
(?<=[^0-9a-zA-Z])([1-9]\d{10})(?=[^0-9a-zA-Z])

7. 계좌번호
(?<=[^0-9a-zA-Z])(\d{3}[\s-:\.])(\d{3}[\s-:\.])(\d{6})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{4}[\s-:\.])(\d{3}[\s-:\.])(\d{6})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{6}[\s-:\.])(\d{2}[\s-:\.])(\d{6})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{6}[\s-:\.])(\d{2}[\s-:\.])(\d{6})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{3}[\s-:\.])(\d{2}[\s-:\.])(\d{5}[\s-:\.])(\d{1})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{3}[\s-:\.])(\d{6}[\s-:\.])(\d{5})(?=[^0-9a-zA-Z])
(?<=[^0-9a-zA-Z])(\d{3}[\s-:\.])(\d{6}[\s-:\.])(\d{2}[\s-:\.])(\d{3})(?=[^0-9a-zA-Z])

8. 외국인 등록번호
(?<=[^0-9a-zA-Z])([0-9][0-9][01][0-9][0-3][0-9][\s-:\.]?)([5-8]\d{6})(?=[^0-9a-zA-Z])

fiddler 검색용
REGEX:([0-9][0-9][01][0-9][0-3][0-9][\s-:\.]?)([1-4]\d{6})(?=[^0-9a-zA-Z])|(?<=[^0-9a-zA-Z])([M|S|R|O|D|m|s|r|o|d][0-9]{8})(?=[^0-9a-zA-Z])(?<=[^0-9a-zA-Z])(\d{2}[\s-:\.])(\d{6}[\s-:\.])(\d{2})(?=[^0-9a-zA-Z])|(?<=[^0-9a-zA-Z])(01[0|1|6|7|8|9][\s-:\.]?)(\d{3,4}[\s-:\.]?)(\d{4})(?=[^0-9a-zA-Z])|(?<=[^0-9a-zA-Z])(\d{4}[\s-:\.])(\d{4}[\s-:\.])(\d{4}[\s-:\.])(\d{4})(?=[^0-9a-zA-Z])|(?<=[^0-9a-zA-Z])([1-9]\d{10})(?=[^0-9a-zA-Z])|(?<=[^0-9a-zA-Z])(\d{4})(\d{4})(\d{4})(\d{4})(?=[^0-9a-zA-Z])
 지갑 주소 0x[0-9a-fA-F]{40}



반응형