Skip to content

Commit 5e2f9d2

Browse files
committed
translate regexp/anchor/article
1 parent 29ce40c commit 5e2f9d2

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
# Anchors: string start ^ and end $
1+
# Anchors: mulai _string_ ^ dan akhiran $
22

3-
The caret `pattern:^` and dollar `pattern:$` characters have special meaning in a regexp. They are called "anchors".
3+
Tanda karakter _caret_ `^` dan tanda _dollar_ `$` memiliki arti spesial pada _regexp_. Tanda-tanda tersebut dipanggil dengan nama _"Ancors"_.
44

5-
The caret `pattern:^` matches at the beginning of the text, and the dollar `pattern:$` -- at the end.
5+
Tanda _caret_ `^` membandingkan awalan dari _text_, dan tanda _dollar_ `$` -- membandingkan akhirannya.
66

7-
For instance, let's test if the text starts with `Mary`:
7+
Contoh, Kita coba jika _text_ nya memiliki awalan `Mary`:
88

99
```js run
1010
let str1 = "Mary had a little lamb";
11-
alert( /^Mary/.test(str1) ); // true
11+
alert(/^Mary/.test(str1)); // true
1212
```
1313

14-
The pattern `pattern:^Mary` means: "string start and then Mary".
14+
Pola `^Mary` berarti: "_text_ nya dimulai dengan Mary"
1515

16-
Similar to this, we can test if the string ends with `snow` using `pattern:snow$`:
16+
Sama seperti ini, kita bisa mencoba jika _text_ nya berakhiran dengan `snow` menggunakan `snow$`:
1717

1818
```js run
1919
let str1 = "it's fleece was white as snow";
20-
alert( /snow$/.test(str1) ); // true
20+
alert(/snow$/.test(str1)); // true
2121
```
2222

23-
In these particular cases we could use string methods `startsWith/endsWith` instead. Regular expressions should be used for more complex tests.
23+
Dalam beberapa kasus tertentu kita bisa menggunakan metode _string_ `startsWith/endsWith`. _Regular Expression_ hanya digunakan untuk _test_ yang lebih kompleks.
2424

25-
## Testing for a full match
25+
## Membandingkan keseluruhannya
2626

27-
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.
27+
Kedua _achors_ `^...%` sering digunakan untuk menguji apakah sebuah _string_ sama keseluruhannya secara pola atau tidak. Contohnya, untuk memeriksa apakah _input_ dari _user_ menggunakan format yang benar.
2828

29-
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.
29+
Kita coba apakah `12:34` adalah format _string_ atau bukan. Menggunakan: dua angka, lalu titik dua, lalu dua angka lagi.
3030

31-
In regular expressions language that's `pattern:\d\d:\d\d`:
31+
Didalam bahasa _regular expressions_ itu adalah `pola:\d\d:\d\d`:
3232

3333
```js run
3434
let goodInput = "12:34";
3535
let badInput = "12:345";
3636

3737
let regexp = /^\d\d:\d\d$/;
38-
alert( regexp.test(goodInput) ); // true
39-
alert( regexp.test(badInput) ); // false
38+
alert(regexp.test(goodInput)); // true
39+
alert(regexp.test(badInput)); // false
4040
```
4141

42-
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.
42+
Disini yang cocok untuk `pola:\d\d:\d\d` harus dimulai dengan `^` dan diakhiri dengan `$` yang mana harus cocok.
4343

44-
The whole string must be exactly in this format. If there's any deviation or an extra character, the result is `false`.
44+
Seluruh _string_ nya harus menggunakan format yang sama. Jika ada yang berbeda atau ada karakter lebih, maka hasilnya akan menjadi `false`.
4545

46-
Anchors behave differently if flag `pattern:m` is present. We'll see that in the next article.
46+
_Anchors_ bertindak berbeda jika tanda `pola:m` ada. Kita akan mempelajarinya di bab selanjutnya.
4747

48-
```smart header="Anchors have \"zero width\""
49-
Anchors `pattern:^` and `pattern:$` are tests. They have zero width.
48+
```smart header="Anchors memiliki "zero width""
49+
Anchors `pola:^` dan `pola:$` adalah test. Keduanya memiliki "zero width".
5050
51-
In other words, they do not match a character, but rather force the regexp engine to check the condition (text start/end).
51+
Dengan kata lain, keduanya tidak mencocokan karakter, akan tetapi memaksa regexp untuk memeriksa kondisi (awal text/akhir text)
5252
```

0 commit comments

Comments
 (0)