차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판이전 판다음 판 | 이전 판 | ||
tech:regex [2014/08/27 05:32] – [반복] V_L | tech:regex [2016/07/12 00:56] (현재) – 바깥 편집 127.0.0.1 | ||
---|---|---|---|
줄 1: | 줄 1: | ||
+ | {{tag> | ||
====== 정규식 (Regular expression)====== | ====== 정규식 (Regular expression)====== | ||
|.|Any character except newline. | | |.|Any character except newline. | | ||
|\\.|A period (and so on for \\*, \\(, \\\\, etc.) | | |\\.|A period (and so on for \\*, \\(, \\\\, etc.) | | ||
- | |^|The start of the string. | | + | |%%^%%|The start of the string. | |
|$|The end of the string. | | |$|The end of the string. | | ||
|\\d, | |\\d, | ||
줄 9: | 줄 10: | ||
|[abc]|Character a, b, or c. | | |[abc]|Character a, b, or c. | | ||
|[a-z]|a through z. | | |[a-z]|a through z. | | ||
- | |[^abc]|Any character except a, b, or c. | | + | |%%[^abc]%%|Any character except a, b, or c. | |
|%%aa|bb%%|Either aa or bb. | | |%%aa|bb%%|Either aa or bb. | | ||
|?|Zero or one of the preceding element. | | |?|Zero or one of the preceding element. | | ||
줄 32: | 줄 33: | ||
예 : aaa$ (문자열의 끝에 aaa를 포함하면 참, 그렇지 않으면 거짓) | 예 : aaa$ (문자열의 끝에 aaa를 포함하면 참, 그렇지 않으면 거짓) | ||
=====문자표현===== | =====문자표현===== | ||
- | (3) . (period) : 임의의 한 문자를 표시 | + | (3) . (period) : 임의의 한 문자를 표시. 단 개행(New line) 제외 |
예 : ^a.c (문자열의 처음에 abc, adc, aZc 등은 참, aa 는 거짓) | 예 : ^a.c (문자열의 처음에 abc, adc, aZc 등은 참, aa 는 거짓) | ||
a..b$ (문자열의 끝에 aaab, abbb, azzb 등을 포함하면 참) | a..b$ (문자열의 끝에 aaab, abbb, azzb 등을 포함하면 참) | ||
줄 88: | 줄 89: | ||
korea|japan|chinese (korea, japan, chinese 중 하나) | korea|japan|chinese (korea, japan, chinese 중 하나) | ||
=== \ (backslash) === | === \ (backslash) === | ||
- | 위에서 사용된 특수 문자들을 정규식내에서 문자를 취급하고 싶을 때 %%'' | + | 위에서 사용된 특수 문자들을 정규식내에서 문자를 취급하고 싶을 때 '' |
예 : filename\.ext (" | 예 : filename\.ext (" | ||
줄 188: | 줄 189: | ||
출처: http:// | 출처: http:// | ||
- | http:// | + | |
- | {{tag> | + | |