Skip to content

Commit 3ff94fd

Browse files
committed
translate until 'summary' section of 09
1 parent 9ee9977 commit 3ff94fd

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

09_regexp.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -631,19 +631,19 @@ console.log(" ".search(/\S/));
631631

632632
Ne yazık ki, eşleşmenin belirli bir konumdan başlaması gerektiğini belirtmenin bir yolu yoktur (`indexOf`'deki ikinci argümanla yaptığımız gibi), bu genellikle kullanışlı olurdu.
633633

634-
## The lastIndex property
634+
## lastIndex özelliği
635635

636636
{{index "exec method", "regular expression"}}
637637

638-
The `exec` method similarly does not provide a convenient way to start searching from a given position in the string. But it does provide an *in*convenient way.
638+
`exec` metodu benzer şekilde, dizinde belirli bir konumdan aramaya başlamanın kolay bir yolunu sağlamaz. Ancak kolay *olmayan*, zor bir yolunu sağlar.
639639

640640
{{index ["regular expression", matching], matching, "source property", "lastIndex property"}}
641641

642-
Regular expression objects have properties. One such property is `source`, which contains the string that expression was created from. Another property is `lastIndex`, which controls, in some limited circumstances, where the next match will start.
642+
Düzenli ifade nesnelerinin özellikleri vardır. Bunlardan biri `source` özelliğidir ve değerinde bu ifadenin oluşturulduğu dizeyi barındırır. Başka bir özellik de `lastIndex`'tir, bazı sınırlı durumlarda bir sonraki eşleşmenin nereden başlayacağını kontrol eder.
643643

644644
{{index [interface, design], "exec method", ["regular expression", global]}}
645645

646-
Those circumstances are that the regular expression must have the global (`g`) or sticky (`y`) option enabled, and the match must happen through the `exec` method. Again, a less confusing solution would have been to just allow an extra argument to be passed to `exec`, but confusion is an essential feature of JavaScript's regular expression interface.
646+
Bu durumlar, düzenli ifadenin global (`g`) veya yapışkan (`y`) seçeneğinin etkinleştirilmiş olması ve eşleşmenin `exec` metodu aracılığıyla gerçekleşmiş olması gereklidir. Tabii, daha az kafa karışıklığına sebep olmak için `exec` metoduna ekstra bir argümanın verilmesine izin verilmesi daha iyi olurdu, ancak karışıklık JavaScript'in düzenli ifade arayüzünün temel bir özelliğidir.
647647

648648
```
649649
let pattern = /y/g;
@@ -657,9 +657,9 @@ console.log(pattern.lastIndex);
657657

658658
{{index "side effect", "lastIndex property"}}
659659

660-
If the match was successful, the call to `exec` automatically updates the `lastIndex` property to point after the match. If no match was found, `lastIndex` is set back to zero, which is also the value it has in a newly constructed regular expression object.
660+
Eşleşme başarılı olduysa, `exec` çağrısı otomatik olarak `lastIndex` özelliğini eşleşmenin sonrasına işaret edecek şekilde günceller. Eğer bir eşleşme bulunamadıysa, `lastIndex` sıfıra, aynı zamanda yeni oluşturulan bir düzenli ifade nesnesinin sahip olduğu değere geri döner.
661661

662-
The difference between the global and the sticky options is that, when sticky is enabled, the match will succeed only if it starts directly at `lastIndex`, whereas with global, it will search ahead for a position where a match can start.
662+
Global ve yapışkan seçenekler arasındaki fark, yapışkan etkinleştirildiğinde, eşleşme ancak `lastIndex`'te doğrudan başlaması durumunda başarılı olacağıdır, global kullanıldığındaysa, bir eşleşmenin başlayabileceği bir konumu arar.
663663

664664
```
665665
let global = /abc/g;
@@ -672,7 +672,7 @@ console.log(sticky.exec("xyz abc"));
672672

673673
{{index bug}}
674674

675-
When using a shared regular expression value for multiple `exec` calls, these automatic updates to the `lastIndex` property can cause problems. Your regular expression might be accidentally starting at an index that was left over from a previous call.
675+
Birden fazla `exec` çağrısı için paylaşılan bir düzenli ifade değeri kullanırken, bu otomatik güncellemeler `lastIndex` özelliğinin değerinde sorunlara neden olabilir. Düzenli ifadeniz yanlışlıkla önceki bir çağrıdan kalan index değerinden başlayabilir.
676676

677677
```
678678
let digit = /\d/g;
@@ -684,20 +684,20 @@ console.log(digit.exec("and now: 1"));
684684

685685
{{index ["regular expression", global], "match method"}}
686686

687-
Another interesting effect of the global option is that it changes the way the `match` method on strings works. When called with a global expression, instead of returning an array similar to that returned by `exec`, `match` will find _all_ matches of the pattern in the string and return an array containing the matched strings.
687+
Global seçeneğin başka bir ilginç etkisi de, dizeler üzerindeki `match` metodunun çalışma şeklini değiştirmesidir. Global bir ifade ile çağrıldığında, `exec` tarafından döndürülen diziye benzer bir dizi döndürmek yerine, `match`, dizedeki desenin _tüm_ eşleşmelerini bulur ve eşleşen dizeleri içeren bir dizi döndürür.
688688

689689
```
690690
console.log("Banana".match(/an/g));
691691
// → ["an", "an"]
692692
```
693693

694-
So be cautious with global regular expressions. The cases where they are necessary—calls to `replace` and places where you want to explicitly use `lastIndex`—are typically the only places where you want to use them.
694+
Dolayısıyla, global düzenli ifadelerle dikkatli olun. Bunların gerekli olduğu durumlar - `replace` çağrıları ve açıkça `lastIndex`'i kullanmak istediğiniz yerler- genellikle bunları kullanmak istediğiniz tek yerlerdir.
695695

696-
### Getting all matches
696+
### Tüm eşleşmeleri alma
697697

698698
{{index "lastIndex property", "exec method", loop}}
699699

700-
A common thing to do is to find all the matches of a regular expression in a string. We can do this by using the `matchAll` method.
700+
Bir dizedeki bir düzenli ifadenin tüm eşleşmelerini bulmanın yaygın bir kullanımı vardır. Bunu `matchAll` metodunu kullanarak yapabiliriz.
701701

702702
```
703703
let input = "A string with 3 numbers in it... 42 and 88.";
@@ -712,14 +712,14 @@ for (let match of matches) {
712712

713713
{{index ["regular expression", global]}}
714714

715-
This method returns an array of match arrays. The regular expression given it _must_ have `g` enabled.
715+
Bu metod, bir dizi eşleşme dizisi döndürür. Verilen düzenli ifadenin _mutlaka_ `g` seçeneği etkinleştirilmiş olmalıdır.
716716

717717
{{id ini}}
718-
## Parsing an INI file
718+
## Bir INI dosyasını ayrıştırma(parse etme)
719719

720720
{{index comment, "file format", "enemies example", "INI file"}}
721721

722-
To conclude the chapter, we'll look at a problem that calls for ((regular expression))s. Imagine we are writing a program to automatically collect information about our enemies from the ((Internet)). (We will not actually write that program here, just the part that reads the ((configuration)) file. Sorry.) The configuration file looks like this:
722+
Bölümü sonlandırmak için, ((düzenli ifade))lere ihtiyaç duyulan bir soruna bakacağız. Düşmanlarımız hakkında ((internet))ten bilgi toplamak için bir program yazdığımızı hayal edin. (Burada aslında bu programı yazmayacağız, sadece ((konfigürasyon)) dosyasını okuyan kısmı yazacağız. Maalesef.) Konfigürasyon dosyası şöyle görünüyor:
723723

724724
```{lang: "null"}
725725
searchengine=https://duckduckgo.com/?q=$1
@@ -740,21 +740,21 @@ outputdir=/home/marijn/enemies/davaeorn
740740

741741
{{index grammar}}
742742

743-
The exact rules for this format (which is a widely used format, usually called an _INI_ file) are as follows:
743+
Bu biçim için kesin kurallar (genellikle _INI_ dosyası olarak adlandırılan yaygın bir biçimdir) şunlardır:
744744

745-
- Blank lines and lines starting with semicolons are ignored.
745+
- Boş satırlar ve noktalı virgül ile başlayan satırlar yoksayılır.
746746

747-
- Lines wrapped in `[` and `]` start a new ((section)).
747+
- [ ve ] içinde sarmalanan satırlar yeni bir ((bölüm)) başlatır.
748748

749-
- Lines containing an alphanumeric identifier followed by an `=` character add a setting to the current section.
749+
- Alfasayısal bir tanımlayıcıyı takiben bir `=` karakter içeren satırlar, mevcut bölüme bir ayar ekler.
750750

751-
- Anything else is invalid.
751+
- Bunlardan başka her şey geçersizdir.
752752

753-
Our task is to convert a string like this into an object whose properties hold strings for settings written before the first section header and subobjects for sections, with those subobjects holding the section's settings.
753+
Görevimiz, böyle bir dizeyi, ilk bölüm başlığından önce yazılan ayarları tutan özelliklere sahip nesneye ve bölümleri tutan alt nesnelerleri barındıran bir nesneye dönüştürmektir.
754754

755755
{{index "carriage return", "line break", "newline character"}}
756756

757-
Since the format has to be processed ((line)) by line, splitting up the file into separate lines is a good start. We saw the `split` method in [Chapter ?](data#split). Some operating systems, however, use not just a newline character to separate lines but a carriage return character followed by a newline (`"\r\n"`). Given that the `split` method also allows a regular expression as its argument, we can use a regular expression like `/\r?\n/` to split in a way that allows both `"\n"` and `"\r\n"` between lines.
757+
Biçimin ((satır)) satır işlenmesini gerektirdiğinden, dosyayı ayrı satırlara ayırmak iyi bir başlangıçtır. `split` metodunu [bölüm ?](data#split) içinde gördük. Ancak, bazı işletim sistemleri, sadece bir yeni satır karakterini değil, bir taşıma dönüş karakteri ve ardından bir yeni satır karakteri (`"\r\n"`) kullanır. `split` metodunun da bir düzenli ifadeyi argüman olarak almasına izin verildiğinden, `/\r?\n/` gibi bir düzenli ifade kullanarak, satırlar arasında hem `"\n"` hem de `"\r\n"` izin veren bir şekilde bölebiliriz.
758758

759759
```{startCode: true}
760760
function parseINI(string) {
@@ -783,25 +783,25 @@ city=Tessaloniki`));
783783

784784
{{index "parseINI function", parsing}}
785785

786-
The code goes over the file's lines and builds up an object. Properties at the top are stored directly into that object, whereas properties found in sections are stored in a separate section object. The `section` binding points at the object for the current section.
786+
Kod, dosyanın satırlarını geçer ve bir nesne oluşturur. Üstteki özellikler doğrudan bu nesneye depolanırken, bölümlerde bulunan özellikler ayrı bir bölüm nesnesine depolanır. `section` bağlantısı, mevcut bölüm için olan nesneye işaret eder.
787787

788-
There are two kinds of significant lines—section headers or property lines. When a line is a regular property, it is stored in the current section. When it is a section header, a new section object is created, and `section` is set to point at it.
788+
İki tür önemli satır vardır - bölüm başlıkları veya özellik satırları. Bir satır normal bir özellik olduğunda, mevcut bölüme depolanır. Bir bölüm başlığı olduğunda, yeni bir bölüm nesnesi oluşturulur ve `section` bunua işaret etmesi için ayarlanır.
789789

790790
{{index "caret character", "dollar sign", boundary}}
791791

792-
Note the recurring use of `^` and `$` to make sure the expression matches the whole line, not just part of it. Leaving these out results in code that mostly works but behaves strangely for some input, which can be a difficult bug to track down.
792+
`^` ve `$` işaretinin ifadenin sadece bir parçası değil, tüm satırı eşleştirmesini sağlamak için tekrar tekrar kullanılmasına dikkat edin. Bunları bırakmak, çoğunlukla işe yarayan ancak bazı girdiler için garip davranan bir kod sonucu ile sonuçlanır, bu da takip edilmesi zor bir hatadır.
793793

794794
{{index "if keyword", assignment, ["= operator", "as expression"]}}
795795

796-
The pattern `if (match = string.match(...))` makes use of the fact that the value of an ((assignment)) expression (`=`) is the assigned value. You often aren't sure that your call to `match` will succeed, so you can access the resulting object only inside an `if` statement that tests for this. To not break the pleasant chain of `else if` forms, we assign the result of the match to a binding and immediately use that assignment as the test for the `if` statement.
796+
`if (match = string.match(...))` kalıbı, bir ((atama)) ifadesinin (`=`) değerinin atanmış değer olduğu gerçeğinden yararlanır. `match` çağrınızın başarılı olacağından emin olamazsınız, bu yüzden sonucu yalnızca bunu test eden bir `if` ifadesi içinde erişebilirsiniz. `else if` zincirini bozmamak için, eşleşmenin sonucunu bir bağlantıya atar ve hemen bu atamayı `if` ifadesi için test olarak kullanırız.
797797

798798
{{index [parentheses, "in regular expressions"]}}
799799

800-
If a line is not a section header or a property, the function checks whether it is a comment or an empty line using the expression `/^\s*(;|$)/` to match lines that either contain only space, or space followed by a semicolon (making the rest of the line a comment). When a line doesn't match any of the expected forms, the function throws an exception.
800+
Bir satır eğer bir bölüm başlığı veya bir özellik değilse, fonksiyon, `/^\s*(;|$)/` ifadesini kullanarak satırın bir yorum veya boş bir satır olup olmadığını kontrol eder. Bir satırın beklenen biçimlerden hiçbirine uymadığı durumda, fonksiyon bir istisna fırlatır.
801801

802-
## Code units and characters
802+
## Kod birimleri ve karakterler
803803

804-
Another design mistake that's been standardized, in JavaScript regular expressions, is that by default, operator like `.` or `?` work on code units, as discussed in [Chapter ?](higher_order#code_units), not actual characters. This means characters that are composed of two code units behave strangely.
804+
JavaScript düzenli ifadelerinde standartlaştırılmış başka bir tasarım hatası da, [bölüm ?](higher_order#code_units) içinde tartışıldığı gibi varsayılan olarak `.` veya `?` gibi operatörlerin gerçek karakterler yerine kod birimleri üzerinde çalışmasıdır. Bu, iki kod biriminden oluşan karakterlerin garip davranmasına neden olur.
805805

806806
```
807807
console.log(/🍎{3}/.test("🍎🍎🍎"));
@@ -812,9 +812,9 @@ console.log(/<.>/u.test("<🌹>"));
812812
// → true
813813
```
814814

815-
The problem is that the 🍎 in the first line is treated as two code units, and the `{3}` part is applied only to the second one. Similarly, the dot matches a single code unit, not the two that make up the rose ((emoji)).
815+
Sorun, birinci satırdaki 🍎 karakterinin iki kod biriminden oluştuğu şekilde işlenmesidir ve `{3}` kısmının yalnızca ikincisi üzerinde uygulanmasıdır. Benzer şekilde, nokta tek bir kod birimini eşleştirir, gül ((emoji))'sini oluşturan ikiyi değil.
816816

817-
You must add the `u` (Unicode) option to your regular expression to make it treat such characters properly.
817+
Bu tür karakterleri uygun bir şekilde işlemesi için düzenli ifadenize `u` (Unicode) seçeneğini eklemeniz gerekir.
818818

819819
```
820820
console.log(/🍎{3}/u.test("🍎🍎🍎"));

0 commit comments

Comments
 (0)