Skip to content

Commit f6422d4

Browse files
translate search part
1 parent 6d44da5 commit f6422d4

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • 9-regular-expressions/01-regexp-introduction

9-regular-expressions/01-regexp-introduction/article.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let regexp = new RegExp(`<${tag}>`); // مانند /<h2>/ اگر در اعلان
8585
```
8686
لطفاً توجه کنید که `match:We` و `match:we` نتیجه یکسانی میدهند، زیرا پرچم `pattern:i` باعث می‌شود که عبارت باقاعده به حروف بزرگ و کوچک حساس نباشد.
8787

88-
2. If there's no such flag it returns only the first match in the form of an array, with the full match at index `0` and some additional details in properties:
88+
2. اگر چنین پرچمی وجود نداشته باشد، فقط اولین تطابق را در یک آرایه، با تطابق کامل در ایندکس `0` و برخی جزئیات اضافی در ویژگی ها بر می گرداند:
8989
```js run
9090
let str = "We will, we will rock you";
9191
@@ -95,14 +95,15 @@ let regexp = new RegExp(`<${tag}>`); // مانند /<h2>/ اگر در اعلان
9595
alert( result.length ); // 1
9696
9797
// Details:
98-
alert( result.index ); // 0 (position of the match)
99-
alert( result.input ); // We will, we will rock you (source string)
98+
alert( result.index ); // 0 (موقعیت تطابق)
99+
alert( result.input ); // We will, we will rock you (رشته منبع)
100100
```
101-
The array may have other indexes, besides `0` if a part of the regular expression is enclosed in parentheses. We'll cover that in the chapter <info:regexp-groups>.
101+
102+
اگر بخشی از عبارت باقاعده در داخل پرانتز قرار بگیرد، ممکن است آرایه، ایندکس های دیگری در کنار ایندکس `0` نیز داشته باشد. ما آن را در فصل <info:regexp-groups> پوشش خواهیم داد.
102103

103-
3. And, finally, if there are no matches, `null` is returned (doesn't matter if there's flag `pattern:g` or not).
104+
3. و در نهایت، اگر هیچ تطابقی وجود نداشته باشد، `null` بر می گرداند. (فرقی نمی‌کند که پرچم `pattern:g` وجود داشته باشد یا خیر).
104105

105-
This a very important nuance. If there are no matches, we don't receive an empty array, but instead receive `null`. Forgetting about that may lead to errors, e.g.:
106+
این یک فرق ریز و بسیار مهم است. اگر هیچ تطابقی وجود نداشته باشد، یک آرایه خالی دریافت نمی‌کنیم، بلکه `null` دریافت می‌ کنیم. فراموش کردن آن ممکن است منجر به خطاهایی شود، به عنوان مثال:
106107

107108
```js run
108109
let matches = "JavaScript".match(/HTML/); // = null
@@ -112,7 +113,7 @@ let regexp = new RegExp(`<${tag}>`); // مانند /<h2>/ اگر در اعلان
112113
}
113114
```
114115

115-
If we'd like the result to always be an array, we can write it this way:
116+
اگر می‌خواهیم نتیجه همواره یک آرایه باشد، می‌ توانیم آن را به این صورت بنویسیم:
116117

117118
```js run
118119
let matches = "JavaScript".match(/HTML/)*!* || []*/!*;

0 commit comments

Comments
 (0)