diff --git a/9-regular-expressions/04-regexp-anchors/1-start-end/solution.md b/9-regular-expressions/04-regexp-anchors/1-start-end/solution.md index 702f992d7..80bbd4151 100644 --- a/9-regular-expressions/04-regexp-anchors/1-start-end/solution.md +++ b/9-regular-expressions/04-regexp-anchors/1-start-end/solution.md @@ -1,5 +1,5 @@ -An empty string is the only match: it starts and immediately finishes. +Tek eşleşme boş bir dizidir: metin başlar ve hemen biter. -The task once again demonstrates that anchors are not characters, but tests. +Bu örnek, çapaların karakterler değil, testler olduğunu bir kez daha gösteriyor. -The string is empty `""`. The engine first matches the `pattern:^` (input start), yes it's there, and then immediately the end `pattern:$`, it's here too. So there's a match. +Dizi (string) boştur `""`. Regexp motoru öncelikle `pattern:^` çapasıyla eşleşir (satır başı), evet burada, daha sonra satır sonu gelir `pattern:$`, satır sonu da burada `""`. Böylece dizi ile kalıp eşleşmiş olur. diff --git a/9-regular-expressions/04-regexp-anchors/1-start-end/task.md b/9-regular-expressions/04-regexp-anchors/1-start-end/task.md index abdfec938..9f9ca008d 100644 --- a/9-regular-expressions/04-regexp-anchors/1-start-end/task.md +++ b/9-regular-expressions/04-regexp-anchors/1-start-end/task.md @@ -1,3 +1,3 @@ # Regexp ^$ -Which string matches the pattern `pattern:^$`? +Hangi dizi(string) `pattern:^$` kalıbı ile eşleşir? diff --git a/9-regular-expressions/04-regexp-anchors/article.md b/9-regular-expressions/04-regexp-anchors/article.md index c34999ee5..da6c98d10 100644 --- a/9-regular-expressions/04-regexp-anchors/article.md +++ b/9-regular-expressions/04-regexp-anchors/article.md @@ -1,34 +1,35 @@ -# Anchors: string start ^ and end $ +# Çapalar: karakter dizisi (string) başlangıç ^ ve bitiş $ -The caret `pattern:^` and dollar `pattern:$` characters have special meaning in a regexp. They are called "anchors". +Düzeltme `pattern:^` ve dolar `pattern:$` işaretlerinin, düzenli ifade (regexp) için özel anlamları vardır. Bunlar "çapalar" olarak adlandırılır. -The caret `pattern:^` matches at the beginning of the text, and the dollar `pattern:$` -- at the end. +Düzeltme işareti `pattern:^` metnin başlangıcı ile dolar işareti ise `pattern:$` -- metnin sonu ile eşleşir. -For instance, let's test if the text starts with `Mary`: +Örneğin, metnin `Mary` ile başlayıp başlamadığını test edelim: ```js run let str1 = "Mary had a little lamb"; alert( /^Mary/.test(str1) ); // true ``` -The pattern `pattern:^Mary` means: "string start and then Mary". +`pattern:^Mary` kalıbının anlamı: "dizi (string) başlangıcı (^) ve ardından Mary". -Similar to this, we can test if the string ends with `snow` using `pattern:snow$`: +Buna benzer olarak, metnin `snow` ile bitip bitmediğini `pattern:snow$` kullanarak test edebiliriz: ```js run let str1 = "it's fleece was white as snow"; alert( /snow$/.test(str1) ); // true ``` -In these particular cases we could use string methods `startsWith/endsWith` instead. Regular expressions should be used for more complex tests. -## Testing for a full match +Bu gibi özel durumlarda (başlangıç ve bitiş), çapaların (^, $) yerine `startsWith/endsWith` string methodlarını kullanabiliriz. Düzenli ifadeler (regexp), karmaşık testler için kullanılmalıdır. -Both anchors together `pattern:^...$` are often used to test whether or not a string fully matches the pattern. For instance, to check if the user input is in the right format. +## Tam eşleşme için test yapmak -Let's check whether or not a string is a time in `12:34` format. That is: two digits, then a colon, and then another two digits. +İki çapanın birlikte kullanımıyla `pattern:^...$`, string ile kalıbın tam olarak eşleşip eşleşmediği kontrol edilir. Örneğin, kullanıcı girişinin doğru biçimde olup olmadığını kontrol edelim. -In regular expressions language that's `pattern:\d\d:\d\d`: +Verilen dizinin (string) `12:34` biçiminde bir zaman olup olmadığını kontrol edelim. Kalıp şu şekilde olmalı: iki basamak, ardından iki nokta üst üste ve iki basamak daha. + +Yukarda bahsedilen kalıp, düzenli ifadeler (RegExp) dilinde `pattern:\d\d:\d\d` karşılık gelir: ```js run let goodInput = "12:34"; @@ -36,17 +37,17 @@ let badInput = "12:345"; let regexp = /^\d\d:\d\d$/; alert( regexp.test(goodInput) ); // true -alert( regexp.test(badInput) ); // false +alert( regexp.test(badInput) ); // false, ":" ifadesinden sonra 2 basamak yerine 3 basamak vardır ``` -Here the match for `pattern:\d\d:\d\d` must start exactly after the beginning of the text `pattern:^`, and the end `pattern:$` must immediately follow. +Burada `pattern:\d\d:\d\d` eşleşmesi yapmak için; metnin başlangıcından `pattern:^` hemen sonra `pattern:\d\d:\d\d` konulmalı ve ardından `pattern:$` eklenmelidir. -The whole string must be exactly in this format. If there's any deviation or an extra character, the result is `false`. +Dizi (string) tam olarak bu kalıpta olmalıdır. Herhangi bir sapma ya da fazla bir karakter varsa sonuç `false` olur. -Anchors behave differently if flag `pattern:m` is present. We'll see that in the next article. +Çapalar, `pattern:m` bayrağı kullanıldığında farklı davranır. Bir sonraki bölümde bu konuya değineceğiz. -```smart header="Anchors have \"zero width\"" -Anchors `pattern:^` and `pattern:$` are tests. They have zero width. +```smart header="Çapalar \"sıfır genişlik\" e sahiptir. Anchors have \"zero width\"" +`pattern:^` ve `pattern:$` çapaları testlerdir. Genişliği yoktur. -In other words, they do not match a character, but rather force the regexp engine to check the condition (text start/end). +Bir başka deyişle, çapalar herhangi bir karakterle eşleşmezler bunun yerine regexp motorunu, kullanılan kalıp için test etmeye zorlar. ```