File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed
9-regular-expressions/09-regexp-quantifiers Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 11
2- Solution :
2+ 정답 :
33
44``` js run
55let regexp = / \. {3,} / g ;
66alert ( " Hello!... How goes?....." .match (regexp) ); // ..., .....
77```
88
9- Please note that the dot is a special character, so we have to escape it and insert as ` \. ` .
9+ 점은 특수문자이므로 ` \. ` 을 삽입해 이스케이프 해야 합니다 .
Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ importance: 5
22
33---
44
5- # How to find an ellipsis " ..." ?
5+ # 생략 부호 ' ...'를 어떻게 찾을 수 있을까요 ?
66
7- Create a regexp to find ellipsis: 3 (or more?) dots in a row .
7+ 연속된 점 3개 혹은 그 이상으로 구성되는 생략 부호를 찾기 위한 정규표현식을 만들어보세요 .
88
9- Check it:
9+ 정답 작성 시, 다음 코드가 정상 동작하게 됩니다.
1010
1111``` js
1212let regexp = / your regexp/ g ;
Original file line number Diff line number Diff line change 1- We need to look for ` # ` followed by 6 hexadecimal characters .
1+ 6개의 16진수가 뒤에 오는 ` # ` 을 찾아야 합니다 .
22
3- A hexadecimal character can be described as ` pattern:[0-9a-fA-F] ` . Or if we use the ` pattern:i ` flag, then just ` pattern:[0-9a-f] ` .
3+ 16진수 문자는 ` pattern:[0-9a-fA-F] ` 와 같이 표현할 수 있습니다. ` pattern:i ` 플래그를 사용하는 경우엔 ` pattern:[0-9a-f] ` 로도 표현 가능합니다 .
44
5- Then we can look for 6 of them using the quantifier ` pattern:{6} ` .
5+ 이후 수량자( quantifier) ` pattern:{6} ` 를 사용해 6개의 16진수를 찾습니다 .
66
7- As a result, we have the regexp: ` pattern:/#[a-f0-9]{6}/gi ` .
7+ 그 결과 ` pattern:/#[a-f0-9]{6}/gi ` 라는 정규표현식이 도출됩니다 .
88
99``` js run
1010let regexp = / #[a-f0-9 ] {6} / gi ;
@@ -14,13 +14,13 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2"
1414alert ( str .match (regexp) ); // #121212,#AA00ef
1515```
1616
17- The problem is that it finds the color in longer sequences:
17+ 그런데 이 정규표현식은 6자리보다 긴 16진수가 뒤에 오는 경우도 검출한다는 문제가 있습니다.
1818
1919``` js run
2020alert ( " #12345678" .match ( / #[a-f0-9 ] {6} / gi ) ) // #123456
2121```
2222
23- To fix that, we can add ` pattern:\b ` to the end:
23+ 이를 해결하려면 정규표현식 끝부분에 ` pattern:\b ` 를 추가하면 됩니다.
2424
2525``` js run
2626// color
Original file line number Diff line number Diff line change 1- # Regexp for HTML colors
1+ # HTML에서 쓰이는 색상 검출을 위한 정규표현식
22
3- Create a regexp to search HTML-colors written as ` #ABCDEF ` : first ` # ` and then 6 hexadecimal characters .
3+ ` #ABCDEF ` 과 같이 HTML에서 사용하는 색상을 검출할 수 있는 정규표션식을 만들어보세요. 해당 색상은 첫 글자 ` # ` 과 6개의 16진수로 구성됩니다 .
44
5- An example of use :
5+ 예시 :
66
77``` js
88let regexp = / ... your regexp... /
@@ -12,4 +12,4 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2 #1234
1212alert ( str .match (regexp) ) // #121212,#AA00ef
1313```
1414
15- P.S. In this task we do not need other color formats like ` #123 ` or ` rgb(1,2,3) ` etc .
15+ 참고: 이 과제에선 ` #123 ` 또는 ` rgb(1,2,3) ` 같은 다른 색상 포맷은 고려하지 않아도 됩니다 .
You can’t perform that action at this time.
0 commit comments