유효성검사 작업할때 맨날 검색하는게 너무 힘들어서 정리해보기 😉
const regex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[?!$^&*])[A-Za-z\d?!$^&*]{8,20}$/;
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
const nameRegex = /^[^~!@#$%^&*()\-=+|\\[\]{};':",./<>?`\s]{1,20}$/;
const numRegex = /^[0-9]*$/;
const phoneRegex = /^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})$/
참고로 정규식을 언어화? 시켜서 좀더 가독성 편하게 만드는 라이브러리가 있다.
https://verbalexpressions.github.io/JSVerbalExpressions/
나중에 시간이 된다면 한번 개인 프로젝트에 사용해봐야겠다.