Regular Expression, Pattern, Matcher



[Regular Expression ]

Text            Meaning

\p{Digit}   Anything recognized as a digit by Unicode.

\d            [0-9]   : 숫자인 것

\D            [^0-9] : 숫자가 아닌 것


\w A shorthand for [a-zA-Z0-9_]

\W A shorthand for [^a-zA-Z0-9_]

\d  A shorthand for [0-9]

\D  A shorthand for [^0-9]

\s  A shorthand for [ \t\n\x0B\f\r]

\S  A shorthand for [^ \t\n\x0B\f\r]

\p{Lower} Any lower case character.

\p{Upper} Any upper case character.

\p{ASCII} Any character with a numeric value between

\0x00 and \0x7F.

\p{Alpha} The union of \p{Lower} and \p{Upper}

\p{Alnum} The union of \p{Alpha} and \p{Digit}

\p{Punct} Any of these characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

\p{Print} The union of \p{Alnum} and \p{Punct}

\p{Blank} A space or tab

\p{Space} Shorthand for: [ \t\n\x0B\f\r]


* A shorthand for {0,}

+ A shorthand for {1,}

? A shorthand for {0,1}


ex)

Pattern p = Pattern.compile("\\d*");

String txt = "The SNX is 18547-2993576-99-8";

Matcher m = p.matcher(txt);

boolean found = m.find();

System.out.println(m.group());


'Programming > JAVA' 카테고리의 다른 글

Java 7의 Recursive Task  (0) 2014.11.05
Regular Expression, Pattern, Matcher  (0) 2012.10.16
Java Pattern, Matcher 정규표현식 사용 검색  (0) 2012.10.04
자바 디컴파일러 링크  (0) 2012.06.07
Maven Junit테스트 실행 생략처리  (0) 2012.06.05
Java Web Start 및 GWT관련  (0) 2012.05.21