반응형
[abc] : a, b or c
괄호안에 있는 문자가 존재하면 true(연결된것은 안됨)
  1. public class Test {
  2.     public static void main(String[] args) {
  3.             Pattern pattern      = Pattern.compile("[ABCD]");
  4.         Matcher matcher = pattern.matcher("A");
  5.         System.out.println(matcher.matches());
  6.     }
  7. }
결과 : true 
if문 쓰는것보다 훨씬 유용한것 같다.  


728x90
반응형

+ Recent posts