Skip to content

Commit f85ec87

Browse files
translate until line-46
1 parent dbab176 commit f85ec87

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

9-regular-expressions/04-regexp-anchors/article.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,27 @@ let str1 = "its fleece was white as snow";
2020
alert( /snow$/.test(str1) ); // درست
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+
در این موارد خاص، می‌توانیم به جای آن از روش‌های رشته‌ای `startsWith/endsWith` استفاده کنیم. برای تست های پیچیده تر باید از عبارات منظم استفاده شود.
2424

25-
## Testing for a full match
25+
## تست برای یک مسابقه کامل
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+
هر دو لنگر با هم `$...^:pattern` اغلب برای آزمایش اینکه آیا یک رشته کاملاً با الگو مطابقت دارد یا نه استفاده می شود. به عنوان مثال، برای بررسی اینکه آیا ورودی کاربر در قالب مناسب است یا خیر.
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.
30-
31-
In regular expressions language that's `pattern:\d\d:\d\d`:
29+
بیایید بررسی کنیم که آیا یک رشته زمان در قالب `12:34` است یا خیر. یعنی: دو رقم، سپس یک دونقطه، و سپس دو رقم دیگر.
3230

31+
در زبان عبارات معمولی `pattern:\d\d:\d\d` است:
3332
```js run
3433
let goodInput = "12:34";
3534
let badInput = "12:345";
3635

3736
let regexp = /^\d\d:\d\d$/;
38-
alert( regexp.test(goodInput) ); // true
39-
alert( regexp.test(badInput) ); // false
37+
alert( regexp.test(goodInput) ); // درست
38+
alert( regexp.test(badInput) ); // نادرست
4039
```
4140

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.
41+
در اینجا تطبیق `pattern:\d\d:\d\d` باید دقیقاً بعد از ابتدای متن `^:pattern` شروع شود و انتهای `$:pattern` باید بلافاصله دنبال شود.
4342

44-
The whole string must be exactly in this format. If there's any deviation or an extra character, the result is `false`.
43+
کل رشته باید دقیقاً در این قالب باشد. اگر انحراف یا یک کاراکتر اضافی وجود داشته باشد، نتیجه `نادرست` است.
4544

4645
Anchors behave differently if flag `pattern:m` is present. We'll see that in the next article.
4746

0 commit comments

Comments
 (0)