You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say we have a string like `+7(903)-123-45-67` and want to find all numbers in it. But unlike before, we are interested not in single digits, but full numbers: `7, 903, 123, 45, 67`.
3
+
문자열 `+7(903)-123-45-67`에서 모든 숫자를 찾고 싶다고 가정해봅시다. 전처럼 한 자리짜리 숫자를 찾던 것과는 달리, `7, 903, 123, 45, 67`처럼 수 전부를 가져오려 합니다.
4
4
5
-
A number is a sequence of 1 or more digits `pattern:\d`. To mark how many we need, we can append a *quantifier*.
5
+
찾으려는 수는 `pattern:\d`가 한 개 이상 나열된(즉, 한 자릿수 이상인) 형태입니다. 표현식의 일치 횟수 지정을 위해 *수량자*를 사용할 수 있습니다.
6
6
7
-
## Quantity {n}
7
+
## 수량 {n}
8
8
9
-
The simplest quantifier is a number in curly braces: `pattern:{n}`.
9
+
`pattern:{n}`은 숫자를 중괄호로 감싼 매우 간결한 형태의 수량자입니다.
10
10
11
-
A quantifier is appended to a character (or a character class, or a `[...]`set etc) and specifies how many we need.
11
+
문자(또는 문자 클래스나 `[...]`문자 집합 등) 뒤에 덧붙여 몇 개를 찾고 싶은지를 표현합니다.
12
12
13
-
It has a few advanced forms, let's see examples:
13
+
이 수량자는 몇 가지 고급 사용 형식을 지원합니다. 예시를 살펴봅시다.
14
14
15
-
The exact count: `pattern:{5}`
16
-
: `pattern:\d{5}` denotes exactly 5 digits, the same as `pattern:\d\d\d\d\d`.
17
-
18
-
The example below looks for a 5-digit number:
15
+
정확한 수 일치: `pattern:{5}`
16
+
: `pattern:\d{5}`는 정확히 다섯 자리의 수를 나타내며, `pattern:\d\d\d\d\d`와 같은 의미를 가집니다.
19
17
18
+
다음은 다섯 자리 숫자를 찾는 예시입니다.
19
+
20
20
```js run
21
-
alert( "I'm 12345 years old".match(/\d{5}/) ); // "12345"
**Regexp "opening or closing HTML-tag without attributes":`pattern:/<\/?[a-z][a-z0-9]*>/i`**
126
+
**'속성이 없는 HTML 시작 태그 또는 종료 태그'에 대한 정규 표현식: `pattern:/<\/?[a-z][a-z0-9]*>/i`**
127
127
128
-
We added an optional slash `pattern:/?`near the beginning of the pattern. Had to escape it with a backslash, otherwise JavaScript would think it is the pattern end.
128
+
표현식의 앞 부분에 `pattern:/?`슬래시(빗금)를 선택 사항으로 지정하였습니다. 자바스크립트가 슬래시를 정규 표현식의 끝을 나타내는 기호로 받아들이지 않도록 슬래시 앞에 역슬래시를 추가하여 이스케이프 처리하였습니다.
```smart header="To make a regexp more precise, we often need make it more complex"
135
-
We can see one common rule in these examples: the more precise is the regular expression -- the longer and more complex it is.
134
+
```smart header="정규 표현식을 보다 정밀하게 만들기 위해서는, 가급적 더 복잡하게 만들어야 합니다"
135
+
지금까지의 예시들을 통해 한 가지 공통된 법칙을 볼 수 있습니다. ‘정규 표현식이 정밀하면 할수록, 그 정규 표현식은 더 길고, 더 복잡하다’는 것입니다.
136
136
137
-
For instance, for HTML tags we could use a simpler regexp: `pattern:<\w+>`. But as HTML has stricter restrictions for a tag name, `pattern:<[a-z][a-z0-9]*>` is more reliable.
137
+
예를 들어 HTML 태그의 경우, `pattern:<\w+>`처럼 간단한 표현식을 사용할 수도 있습니다. 하지만 HTML의 태그 이름에 관한 엄격한 규칙을 감안하면 `pattern:<[a-z][a-z0-9]*>`이 더 안전합니다.
138
138
139
-
Can we use `pattern:<\w+>` or we need `pattern:<[a-z][a-z0-9]*>`?
139
+
`pattern:<\w+>`을 써도 괜찮은 걸까요? 아니면 `pattern:<[a-z][a-z0-9]*>`을 써야 하는 걸까요?
140
140
141
-
In real life both variants are acceptable. Depends on how tolerant we can be to "extra" matches and whether it's difficult or not to remove them from the result by other means.
141
+
실제 사용할 때에 있어서는 둘 다 적합합니다. 원하는 일치 항목 외에 “부수적인” 일치 항목들을 얼마나 허용할 건지, 다른 방식으로 해당 항목들을 제거하는 데 어려움이 따르는지 여부에 따라 결정하면 됩니다.
0 commit comments