This is an old revision of the document!


정규식

Java에서 아래와 같은 구문으로 이용한다.

Pattern p = Pattern.compile("^REGULAR_EXPRESSION$");
Matcher m = p.matcher(STRING);
boolean b = m.matches();

전화번호

^(02|0[3-6]{1}[1-5]{1})-?[0-9]{3,4}-?[0-9]{4}$ //지역번호-xxx(x)-xxxx
^(15(44|77|88|99)|1644)-?[0-9]{4}$ //15xx/1644-xxxx

소괄호 안 문자(= Parameter) 추출

String str = "(int a, int b)";

Pattern p = Pattern.compile("\\((.*?)\\)");
Matcher m = p.matcher(str);

while(m.find())
	System.out.println(m.group(1));

regular_expression.1442074960.txt.gz · Last modified: 2021/02/07 03:15 (external edit)