정규식

Jinjin·2023년 10월 18일
0

🔔 정규식

1. Pattern 클래스

String pattern = "^[0-9]*$"; // 숫자만 등장하는지
String str = "123321"; 

boolean result = Pattern.matches(pattern, str);
System.out.println(result); // true

2. Matcher 클래스

Pattern pattern = Pattern.compile("^[0-9]*$");
String str = "04234234";

Matcher matcher = pattern.matcher(str);
System.out.println(matcher.find());

https://hbase.tistory.com/160

profile
BE Developer

0개의 댓글