import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Home {
public static void main(String[] args){
String pwd = "aAASDF234230`~!@#$%sdsdf2134234$#^%$&*%*)^&*()-_=+{}[]\\\\|;:,.<>/?'";
String ptn="^[\\p{Graph}]*$";
/*
* \\p{Lower},\\p{Upper}
* >> \\p{Alpha}
* \\p{Digit}
* >> \\p{Alnum}
* \\p{Punct}
* >> \\p{Graph}
*/
Pattern p = Pattern.compile(ptn);
Matcher m = p.matcher(pwd);
if(!m.matches()){
System.out.println("p : 틀림");
}else{
System.out.println("p : 맞음");
}
String regex = "^[a-zA-Z0-9`~!@#$%^&*()-=_+\\[\\]{}:;',./<>?\\\\|]*$";
Pattern p1 = Pattern.compile(regex);
if(p1.matcher("123avcASGD#$%&'A()*+,-./:;<=>?@[\\gsf]^_`{df|2134}~").matches()){
System.out.println("p1 : good");
}else{
System.out.println("p1 : bad");
}
String regex2 = "^[a-zA-Z0-9!#$%^\\p{Punct}]*$";
Pattern p3 = Pattern.compile(regex2);
if(p3.matcher("@##&23aGD#$%&'A()*+,-;;;'''@#$adsfasdSDFBFDB12414$^&^.?@[\\gsf]^_`{df|4}~").matches()){
System.out.println("p3 : good");
}else{
System.out.println("p3 : bad");
}
}
}
'Web Programming > java-jsp' 카테고리의 다른 글
display:block 테이블깨짐현상 (2) | 2014.06.30 |
---|---|
STS.ini 설정해서 빠르게! (0) | 2014.05.21 |
http, https 의 상대주소 (0) | 2014.05.08 |
객체 지향 설계 원칙 solid (0) | 2014.04.21 |
telnet 포트확인 (0) | 2014.03.21 |