본문 바로가기

개발/JS

[JS] 이메일 정규식

RFC 5322 기준

/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

수정된 버전 (유저네임 제한)

/^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

수정된 버전 2 (숫자 도메인 불가능)

/^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/


참고: https://webcache.googleusercontent.com/search?q=cache:514Y4NDdl6sJ:https://emailregex.com/+&cd=1&hl=ko&ct=clnk&gl=kr