Both sides previous revisionPrevious revisionNext revision | Previous revision |
regular_expression [2022/10/16 14:26] – Lookaround 내용 정리 ledyx | regular_expression [2022/10/16 16:21] (current) – 문단 수정 ledyx |
---|
| |
| |
| = 언어별 활용 = |
| |
= Java = | == Java == |
| |
https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html | https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html |
</sxh> | </sxh> |
| |
== Pattern Constant == | === Pattern Constant === |
| |
<sxh> | <sxh> |
</sxh> | </sxh> |
| |
== POSIX character classes (US-ASCII only) == | === POSIX character classes (US-ASCII only) === |
| |
<sxh> | <sxh> |
\p{XDigit} A hexadecimal digit: [0-9a-fA-F] | \p{XDigit} A hexadecimal digit: [0-9a-fA-F] |
\p{Space} A whitespace character: [ \t\n\x0B\f\r] | \p{Space} A whitespace character: [ \t\n\x0B\f\r] |
</sxh> | |
= 활용 = | |
| |
== 전화번호 == | |
<sxh java> | |
^(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 | |
</sxh> | |
| |
== 소괄호 안 문자(= Parameter) 추출 == | |
<sxh java> | |
String str = "(int a, int b)"; | |
| |
Pattern p = Pattern.compile("\\((.*?)\\)"); | |
Matcher m = p.matcher(str); | |
| |
while(m.find()) | |
System.out.println(m.group(1)); | |
</sxh> | </sxh> |
| |