Skip to content

Commit e53b308

Browse files
authored
Merge pull request #326 from yinkar/master
Word boundary: \b
2 parents b1969dc + 1901a5a commit e53b308

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
The answer: `pattern:\b\d\d:\d\d\b`.
2+
Yanıt: `pattern:\b\d\d:\d\d\b`.
33

44
```js run
5-
alert( "Breakfast at 09:00 in the room 123:456.".match( /\b\d\d:\d\d\b/ ) ); // 09:00
5+
alert( "Kahvaltı 09:00'da oda 123:456'da.".match( /\b\d\d:\d\d\b/ ) ); // 09:00
66
```
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Find the time
1+
# Zamanı bul
22

3-
The time has a format: `hours:minutes`. Both hours and minutes has two digits, like `09:00`.
3+
Zaman, `saat:dakika` şeklinde bir formata sahiptir. Ancak saat ve dakika iki basamaklıdır, `09:00` gibi.
44

5-
Make a regexp to find time in the string: `subject:Breakfast at 09:00 in the room 123:456.`
5+
`subject:Kahvaltı 09:00'da oda 123:456'da.` karakter dizisi için zamanı bulacak bir regexp yazın.
66

7-
P.S. In this task there's no need to check time correctness yet, so `25:99` can also be a valid result.
7+
Not: Bu görevde zamanın doğruluğunu kontrol etmeye gerek yok, bu nedenle `25:99` gibi bir saat dahi doğru bir sonuç olarak kabul edilebilir.
88

9-
P.P.S. The regexp shouldn't match `123:456`.
9+
Not: Regexp, `123:456` ile eşleşmemeli.
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
1-
# Word boundary: \b
1+
# Kelime sınırı: \b
22

3-
A word boundary `pattern:\b` is a test, just like `pattern:^` and `pattern:$`.
3+
Bir kelime sınırı `pattern:\b`, tıpkı `pattern:^` ve `pattern:$` gibi bir testtir.
44

5-
When the regexp engine (program module that implements searching for regexps) comes across `pattern:\b`, it checks that the position in the string is a word boundary.
5+
Regexp motoru (regexpleri aramak için oluşturulmuş program modülü), `pattern:\b` ile karşılaştığında karakter dizisindeki konumun bir kelime sınırı olup olmadığını kontrol eder.
66

7-
There are three different positions that qualify as word boundaries:
7+
Sözcük sınırı olarak nitelendirilen üç adet durum vardır:
88

9-
- At string start, if the first string character is a word character `pattern:\w`.
10-
- Between two characters in the string, where one is a word character `pattern:\w` and the other is not.
11-
- At string end, if the last string character is a word character `pattern:\w`.
9+
- Karakter dizisi başlangıcında. Şayet ilk karakter dizisi karakteri bir kelime karakteriyse `pattern:\w`.
10+
- Karakter dizisinin iki karakterinin arası. Bir tanesi kelime karakteri `pattern:\w` ise ve diğeri değilse.
11+
- Karakter dizisi sonunda. Eğer son karakter dizisi karakter bir kelime karakteriyse `pattern:\w`.
1212

13-
For instance, regexp `pattern:\bJava\b` will be found in `subject:Hello, Java!`, where `subject:Java` is a standalone word, but not in `subject:Hello, JavaScript!`.
13+
Örneğin, regexp `pattern:\bJava\b` ifadesi `subject:Merhaba, Java!` içerisinde bulunacaktır, burada `subject:Java` bağımsız bir kelimedir. Ancak `subject:Merhaba, JavaScript!` içerisinde bulunmaz.
1414

1515
```js run
16-
alert( "Hello, Java!".match(/\bJava\b/) ); // Java
17-
alert( "Hello, JavaScript!".match(/\bJava\b/) ); // null
16+
alert( "Merhaba, Java!".match(/\bJava\b/) ); // Java
17+
alert( "Merhaba, JavaScript!".match(/\bJava\b/) ); // null
1818
```
1919

20-
In the string `subject:Hello, Java!` following positions correspond to `pattern:\b`:
20+
`subject:Hello, Java!` karakter dizisinde aşağıdaki pozisyonlar `pattern:\b`'ye karşılık gelir.
2121

2222
![](hello-java-boundaries.svg)
2323

24-
So, it matches the pattern `pattern:\bHello\b`, because:
2524

26-
1. At the beginning of the string matches the first test `pattern:\b`.
27-
2. Then matches the word `pattern:Hello`.
28-
3. Then the test `pattern:\b` matches again, as we're between `subject:o` and a space.
25+
Sonuç olarak `pattern:\Merhaba\b` ifadesiyle eşleşir, çünkü:
2926

30-
The pattern `pattern:\bJava\b` would also match. But not `pattern:\bHell\b` (because there's no word boundary after `l`) and not `Java!\b` (because the exclamation sign is not a wordly character `pattern:\w`, so there's no word boundary after it).
27+
1. Karakter dizisinin başlangıcı ilk `pattern:\b` testi ile eşleşir.
28+
2. Sonrasında `pattern:Merhaba` kelimesi eşleşir.
29+
3. Ardından `pattern:\b`, `subject:o` ile bir boşluk arasında bulunduğumuzdan dolayı tekrar eşleşir.
30+
31+
Aynı şekilde `pattern:\bJava\b` şablonu de eşleşecektir. Ancak `pattern:\bMerh\b` eşleşmez, (çünkü `b`'den sonra bir kelime sınırı yoktur), aynı şekilde `Java!\b` da (çünkü ünlem işareti `pattern:\w` ile ifade edilen bir kelime karakteri değildir), dolayısıyla sonrasında bir kelime sınırı yoktur.
3132

3233
```js run
33-
alert( "Hello, Java!".match(/\bHello\b/) ); // Hello
34-
alert( "Hello, Java!".match(/\bJava\b/) ); // Java
35-
alert( "Hello, Java!".match(/\bHell\b/) ); // null (no match)
36-
alert( "Hello, Java!".match(/\bJava!\b/) ); // null (no match)
34+
alert( "Merhaba, Java!".match(/\bMerhaba\b/) ); // Merhaba
35+
alert( "Merhaba, Java!".match(/\bJava\b/) ); // Java
36+
alert( "Merhaba, Java!".match(/\bMerh\b/) ); // null (eşleşme yok)
37+
alert( "Merhaba, Java!".match(/\bJava!\b/) ); // null (eşleşme yok)
3738
```
3839

39-
We can use `pattern:\b` not only with words, but with digits as well.
40+
`pattern:\b`'yi yalnızca kelimelerle değil, rakamlarla da kullanabiliriz.
4041

41-
For example, the pattern `pattern:\b\d\d\b` looks for standalone 2-digit numbers. In other words, it looks for 2-digit numbers that are surrounded by characters different from `pattern:\w`, such as spaces or punctuation (or text start/end).
42+
Örnek vermek gerekirse, `pattern:\b\d\d\b` şablonu 2 basamaklı sayılara bakacaktır. Başka bir deyişle, `pattern:\w`'den başka, boşluk veya noktalama işareti olmayan (veya metin başlangıcı/bitişi) karakterlerle çevrili bağımsız 2 basamaklı sayılara bakacaktır.
4243

4344
```js run
4445
alert( "1 23 456 78".match(/\b\d\d\b/g) ); // 23,78
4546
alert( "12,34,56".match(/\b\d\d\b/g) ); // 12,34,56
4647
```
4748

48-
```warn header="Word boundary `pattern:\b` doesn't work for non-latin alphabets"
49-
The word boundary test `pattern:\b` checks that there should be `pattern:\w` on the one side from the position and "not `pattern:\w`" - on the other side.
49+
```warn header="Word boundary `pattern:\b` Latin alfabesi haricinde çalışmaz"
50+
51+
Kelime sınırı testi `pattern:\b`, bir yanda `pattern:\w`, diğer yanda `pattern:\w` olmamama durumununun söz konusu olduğu pozisyonları kontrol eder.
5052

51-
But `pattern:\w` means a latin letter `a-z` (or a digit or an underscore), so the test doesn't work for other characters, e.g. cyrillic letters or hieroglyphs.
53+
Ancak `pattern:\w`, `a-z` şeklinde bir latin harfi (veya harf veya alt tire) anlamına gelir, sonuç olarak test Kiril veya Hiyeroglif gibi farklı karakterler için çalışmayacaktır.
5254
```

0 commit comments

Comments
 (0)