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
+
Diyelim ki `+7(903)-123-45-67`şeklinde bir karakter dizimiz var ve biz bu dizideki sayıların tamamını bulmak istiyoruz. Ama öncekinden farklı olarak, tek bir sayıyla değil, bütün sayılarla ilgileniyoruz: `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
+
Sayı, bir veya daha fazla rakamdan oluşan bir dizidir `pattern:\d`. Kaç tanesine sahip olduğumuzu işaretlemek için bir *nicelik belirteci* ekleyebiliriz.
6
6
7
-
## Quantity {n}
7
+
## Nicelik {n}
8
8
9
-
The simplest quantifier is a number in curly braces: `pattern:{n}`.
9
+
En basit nicelik belirteci, süslü parantezler içindeki bir sayıdır: `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
+
Bir karaktere (ya da bir karakter sınıfına, veya `[...]`kümesine vb.) nicelik belirteci eklendiğinde, bize kaç tanesine sahip olduğumuzu belirtir.
12
12
13
-
It has a few advanced forms, let's see examples:
13
+
Birkaç gelişmiş formu var, örneklere bakalım:
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`.
15
+
Tam sayım: `pattern:{5}`
16
+
: `pattern:\d{5}`, `pattern:\d\d\d\d\d` ile benzerdir. İkiside tam olarak 5 adet rakamı belirtir.
17
17
18
-
The example below looks for a 5-digit number:
18
+
Aşağıdaki örnekte 5 basamaklı sayı aranır:
19
19
20
20
```js run
21
-
alert( "I'm 12345 years old".match(/\d{5}/) ); // "12345"
We can add `\b` to exclude longer numbers: `pattern:\b\d{5}\b`.
24
+
Daha uzun sayıları hariç tutmak için `\b` kullanabiliriz: `pattern:\b\d{5}\b`.
25
25
26
-
The range: `pattern:{3,5}`, match 3-5 times
27
-
: To find numbers from 3 to 5 digits we can put the limits into curly braces: `pattern:\d{3,5}`
26
+
`pattern:{3,5}`, 3 ila 5 aralığında eşleştirir
27
+
: 3 ila 5 basamaklı sayıları bulmak için sınırları süslü parantezlerin içinde belirtebiliriz: `pattern:\d{3,5}`
28
28
29
29
```js run
30
-
alert( "I'm not 12, but 1234 years old".match(/\d{3,5}/) ); // "1234"
30
+
alert( "12 yaşında değilim, 1234 yaşındayım.".match(/\d{3,5}/) ); // "1234"
31
31
```
32
32
33
-
We can omit the upper limit.
33
+
Üst sınırı kaldırabiliriz.
34
34
35
-
Then a regexp `pattern:\d{3,}` looks for sequences of digits of length `3` or more:
35
+
`pattern:\d{3,}`, `3` veya daha fazla basamaklı sayıları arar:
36
36
37
37
```js run
38
-
alert( "I'm not 12, but 345678 years old".match(/\d{3,}/) ); // "345678"
38
+
alert( "12 yaşında değilim, 345678 yaşındayım".match(/\d{3,}/) ); // "345678"
39
39
```
40
40
41
-
Let's return to the string `+7(903)-123-45-67`.
41
+
Şimdi `+7(903)-123-45-67` değerine dönelim.
42
42
43
-
A number is a sequence of one or more digits in a row. So the regexp is`pattern:\d{1,}`:
43
+
Sayı, arka arkaya bir veya daha fazla rakamdan oluşan bir dizidir. Yani düzenli ifade (regexp) şu şekilde olacaktır,`pattern:\d{1,}`:
44
44
45
45
```js run
46
46
let str ="+7(903)-123-45-67";
@@ -50,14 +50,14 @@ let numbers = str.match(/\d{1,}/g);
50
50
alert(numbers); // 7,903,123,45,67
51
51
```
52
52
53
-
## Shorthands
53
+
## Kısaltmalar
54
54
55
-
There are shorthands for most used quantifiers:
55
+
Çok kullanılan nicelik belirteçlerinin kısaltmaları mevcuttur:
56
56
57
57
`pattern:+`
58
-
: Means "one or more", the same as `pattern:{1,}`.
58
+
: "bir veya daha fazlası" anlamına gelir, `pattern:{1,}` ifadesine benzerdir.
59
59
60
-
For instance, `pattern:\d+` looks for numbers:
60
+
Örneğin, `pattern:\d+` sayıları aramak içindir:
61
61
62
62
```js run
63
63
let str = "+7(903)-123-45-67";
@@ -66,11 +66,11 @@ There are shorthands for most used quantifiers:
66
66
```
67
67
68
68
`pattern:?`
69
-
: Means "zero or one", the same as `pattern:{0,1}`. In other words, it makes the symbol optional.
69
+
: "sıfır ya da bir" anlamına gelir, `pattern:{0,1}` ifadesine benzerdir. Başka bir deyişle, isteğe bağlı hale getirir.
70
70
71
-
For instance, the pattern `pattern:ou?r` looks for `match:o` followed by zero or one `match:u`, and then `match:r`.
71
+
Örneğin, `pattern:ou?r` kalıbı, ilk önce `match:o` için, ardından `match:u` (sıfır veya bir adet) için, ve daha sonrasında `match:r` için arama yapar.
72
72
73
-
So, `pattern:colou?r` finds both `match:color` and `match:colour`:
73
+
Yani, `pattern:colou?r`, hem `match:color` hem de `match:colour` öğelerini bulur:
74
74
75
75
```js run
76
76
let str = "Should I write color or colour?";
@@ -79,64 +79,63 @@ There are shorthands for most used quantifiers:
79
79
```
80
80
81
81
`pattern:*`
82
-
: Means "zero or more", the same as `pattern:{0,}`. That is, the character may repeat any times or be absent.
82
+
: "Sıfır veya daha fazlası" anlamına gelir, `pattern:{0,}` ile benzerdir. Yani bir karakter kendini tekrar edebilir veya hiç olmayabilir:
83
83
84
-
For example, `pattern:\d0*` looks for a digit followed by any number of zeroes (may be many or none):
84
+
Örnek olarak, `pattern:\d0*`, bir sayı ve ardından onu takip eden sıfırları arar (çok sayıda sıfır olabilir ya da hiç olmayabilir):
85
85
86
86
```js run
87
87
alert( "100 10 1".match(/\d0*/g) ); // 100, 10, 1
88
88
```
89
89
90
-
Compare it with `pattern:+` (one or more):
90
+
Bunu `pattern:+` (bir veya daha fazlası) ile karşılaştıralım:
91
91
92
92
```js run
93
93
alert( "100 10 1".match(/\d0+/g) ); // 100, 10
94
-
// 1 not matched, as 0+ requires at least one zero
94
+
// 1 eşleşmedi, çünkü 0+ ifadesi en az bir sıfır varlığını gerektirir.
95
95
```
96
96
97
-
## More examples
97
+
## Daha Fazla Örnek
98
98
99
-
Quantifiers are used very often. They serve as the main "building block" of complex regular expressions, so let's see more examples.
99
+
Nicelik belirteçleri sıklıkla kullanılır. Karmaşık düzenli ifade kalıplarının (regexp pattern) "yapı taşı" olarak kullanılırlar. Bu yüzden daha fazla örnek görelim.
100
100
101
-
**Regexp for decimal fractions (a number with a floating point): `pattern:\d+\.\d+`**
101
+
**Ondalık kesirler için düzenli ifadeler (regexp) (kayan noktalı bir sayı): `pattern:\d+\.\d+`**
The regexp looks for character `pattern:'<'`followed by one or more Latin letters, and then `pattern:'>'`.
115
+
Bu düzenli ifade (regexp), ilk olarak `pattern:'<'`için, ardından bir veya daha fazla Latin harfi için ve daha sonrasında `pattern:'>'` için bir arama yapar.
117
116
118
-
2.Improved:`pattern:/<[a-z][a-z0-9]*>/i`
117
+
2.Gelişmiş hali:`pattern:/<[a-z][a-z0-9]*>/i`
119
118
120
-
According to the standard, HTMLtag name may have a digit at any position except the first one, like `<h1>`.
119
+
Standarda göre HTMLetiket isimleri `<h1>` gibi ilk karakter dışında herhangi bir pozisyonda bir rakam içerebilir.
**Regexp "opening or closing HTML-tag without attributes":`pattern:/<\/?[a-z][a-z0-9]*>/i`**
125
+
**"Nitelik barındırmayan HTML açılış ve kapanış etiketleri" için düzenli ifade (regexp):`pattern:/<\/?[a-z][a-z0-9]*>/i`**
127
126
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.
127
+
Kalıbın başında `pattern:/?`ile isteğe bağlı bir eğik çizgi (slash) belirttim. Ters eğik çizgiyle (backslash) bundan kurtuldum, aksi takdirde JavaScript bunun, düzenli ifade kalıbının sonu olduğunu düşünecekti.
```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.
133
+
```smart header="Bir düzenli ifadeyi daha tutarlı/kesin hale getirmek için genellikle onu daha karmaşık hale getirmek gerekir"
134
+
Bu örneklerde genel bir kural görebiliriz: düzenli ifade ne kadar tutarlı/kesin ise o kadar uzun ve karmaşıktır.
136
135
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.
136
+
Örneğin, HTML etiketleri için daha basit bir ifade kullanabiliriz: `pattern:<\w+>`. Ancak HTML, etiket isimleri için kısıtlamalara sahip olduğundan dolayı, `pattern:<[a-z][a-z0-9]*>`daha güvenilirdir.
138
137
139
-
Can we use `pattern:<\w+>`or we need `pattern:<[a-z][a-z0-9]*>`?
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.
140
+
Gerçek hayatta ikiside kabul edilebilir. "Ekstra" eşleşmelere ne kadar tahammül edebileceğimize ya da bunları başka yollarla sonuçtan çıkarmanın zor olup olmadığına bağlıdır.
0 commit comments