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 1
1
2
- Solution :
2
+ 정답 :
3
3
4
4
``` js run
5
5
let regexp = / \. {3,} / g ;
6
6
alert ( " Hello!... How goes?....." .match (regexp) ); // ..., .....
7
7
```
8
8
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
2
2
3
3
---
4
4
5
- # How to find an ellipsis " ..." ?
5
+ # 생략 부호 ' ...'를 어떻게 찾을 수 있을까요 ?
6
6
7
- Create a regexp to find ellipsis: 3 (or more?) dots in a row .
7
+ 연속된 점 3개 혹은 그 이상으로 구성되는 생략 부호를 찾기 위한 정규표현식을 만들어보세요 .
8
8
9
- Check it:
9
+ 정답 작성 시, 다음 코드가 정상 동작하게 됩니다.
10
10
11
11
``` js
12
12
let 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진수가 뒤에 오는 ` # ` 을 찾아야 합니다 .
2
2
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] ` 로도 표현 가능합니다 .
4
4
5
- Then we can look for 6 of them using the quantifier ` pattern:{6} ` .
5
+ 이후 수량자( quantifier) ` pattern:{6} ` 를 사용해 6개의 16진수를 찾습니다 .
6
6
7
- As a result, we have the regexp: ` pattern:/#[a-f0-9]{6}/gi ` .
7
+ 그 결과 ` pattern:/#[a-f0-9]{6}/gi ` 라는 정규표현식이 도출됩니다 .
8
8
9
9
``` js run
10
10
let regexp = / #[a-f0-9 ] {6} / gi ;
@@ -14,13 +14,13 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2"
14
14
alert ( str .match (regexp) ); // #121212,#AA00ef
15
15
```
16
16
17
- The problem is that it finds the color in longer sequences:
17
+ 그런데 이 정규표현식은 6자리보다 긴 16진수가 뒤에 오는 경우도 검출한다는 문제가 있습니다.
18
18
19
19
``` js run
20
20
alert ( " #12345678" .match ( / #[a-f0-9 ] {6} / gi ) ) // #123456
21
21
```
22
22
23
- To fix that, we can add ` pattern:\b ` to the end:
23
+ 이를 해결하려면 정규표현식 끝부분에 ` pattern:\b ` 를 추가하면 됩니다.
24
24
25
25
``` js run
26
26
// color
Original file line number Diff line number Diff line change 1
- # Regexp for HTML colors
1
+ # HTML에서 쓰이는 색상 검출을 위한 정규표현식
2
2
3
- Create a regexp to search HTML-colors written as ` #ABCDEF ` : first ` # ` and then 6 hexadecimal characters .
3
+ ` #ABCDEF ` 과 같이 HTML에서 사용하는 색상을 검출할 수 있는 정규표션식을 만들어보세요. 해당 색상은 첫 글자 ` # ` 과 6개의 16진수로 구성됩니다 .
4
4
5
- An example of use :
5
+ 예시 :
6
6
7
7
``` js
8
8
let regexp = / ... your regexp... /
@@ -12,4 +12,4 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2 #1234
12
12
alert ( str .match (regexp) ) // #121212,#AA00ef
13
13
```
14
14
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