This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| regular_expression [2022/10/16 13:14] – 문단 정리 ledyx | regular_expression [2022/10/16 15:21] (current) – 문단 수정 ledyx | ||
|---|---|---|---|
| Line 102: | Line 102: | ||
| == Lookaround == | == Lookaround == | ||
| - | 일치하는 영역을 제외하고, | + | 일치하는 영역을 제외하고, |
| - | === Lookahead === | + | 부정형은 "< |
| - | 전방 탐색 | + | |< |
| + | ^ Metacharacter | ||
| + | | < | ||
| + | | < | ||
| - | | + | ^ Metacharacter |
| - | * Negative | + | | < |
| + | | < | ||
| + | === 예시 === | ||
| + | |||
| + | * 긍정형 전방탐색 | ||
| < | < | ||
| Line 119: | Line 126: | ||
| <bg skyblue> | <bg skyblue> | ||
| <bg skyblue> | <bg skyblue> | ||
| + | |||
| + | * 긍정형 후방탐색 | ||
| + | |||
| + | < | ||
| + | (?< | ||
| + | </ | ||
| + | |||
| + | A11 : $<bg skyblue> | ||
| + | B22 : $<bg skyblue> | ||
| + | Total items found : 2 | ||
| + | |||
| + | * 부정형 전후방탐색 | ||
| + | |||
| + | < | ||
| + | \b(?< | ||
| + | </ | ||
| + | |||
| + | I paid $30 for <bg skyblue> | ||
| + | <bg skyblue> | ||
| + | I saved $5 on this order. | ||
| Line 140: | Line 167: | ||
| - | === Lookbehind | ||
| - | 후방 탐색. | ||
| - | * Positive : < | + | = 언어별 활용 = |
| - | * Negative : < | + | |
| - | < | + | == Java == |
| - | (?<=\$)[0-9.]+ | + | |
| - | </ | + | |
| - | + | ||
| - | A11 : $<bg skyblue> | + | |
| - | B22 : $<bg skyblue> | + | |
| - | Total items found : 2 | + | |
| - | + | ||
| - | + | ||
| - | = Java = | + | |
| https:// | https:// | ||
| Line 165: | Line 180: | ||
| </ | </ | ||
| - | == Pattern Constant == | + | === Pattern Constant |
| <sxh> | <sxh> | ||
| Line 177: | Line 192: | ||
| </ | </ | ||
| - | == POSIX character classes (US-ASCII only) == | + | === POSIX character classes (US-ASCII only) === |
| <sxh> | <sxh> | ||
| Line 193: | Line 208: | ||
| \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 java> | ||
| - | ^(02|0[3-6]{1}[1-5]{1})-? | ||
| - | ^(15(44|77|88|99)|1644)-? | ||
| - | </ | ||
| - | |||
| - | == 소괄호 안 문자(= 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)); | ||
| </ | </ | ||