Skip to content

Commit 8e5276e

Browse files
finish article
1 parent 4a9a273 commit 8e5276e

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

  • 9-regular-expressions/02-regexp-character-classes

9-regular-expressions/02-regexp-character-classes/article.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,29 +159,30 @@ alert( "A\nB".match(/A[\s\S]B/) ); // A\nB (!مطابقت دارد)
159159
````
160160

161161
````warn header="Pay attention to spaces"
162-
Usually we pay little attention to spaces. For us strings `subject:1-5` and `subject:1 - 5` are nearly identical.
162+
معمولا ما به فضاها توجه کمی می کنیم. برای ما رشته های `subject:1-5` و `subject:1 - 5` تقریباً یکسان هستند.
163163
164-
But if a regexp doesn't take spaces into account, it may fail to work.
164+
اما اگر یک regexp فضاها را در نظر نگیرد، ممکن است کار نکند.
165165
166-
Let's try to find digits separated by a hyphen:
166+
بیایید سعی کنیم ارقامی را که با خط فاصله جدا شده اند پیدا کنیم:
167167
168168
```js run
169-
alert( "1 - 5".match(/\d-\d/) ); // null, no match!
169+
alert( "1 - 5".match(/\d-\d/) ); // null, مطابقت ندارد!
170170
```
171171
172-
Let's fix it adding spaces into the regexp `pattern:\d - \d`:
172+
بیایید با افزودن فاصله به regexp به صورت `pattern:\d - \d آن را برطرف کنیم:
173173
174174
```js run
175-
alert( "1 - 5".match(/\d - \d/) ); // 1 - 5, now it works
176-
// or we can use \s class:
177-
alert( "1 - 5".match(/\d\s-\s\d/) ); // 1 - 5, also works
175+
alert( "1 - 5".match(/\d - \d/) ); // 1 - 5, حال درست کار می کند
176+
// یا می توانیم از کلاس s\ استفاده کنیم:
177+
alert( "1 - 5".match(/\d\s-\s\d/) ); // 1 - 5, این نیز کار می کند
178178
```
179179
180-
**A space is a character. Equal in importance with any other character.**
180+
**فضا یک کاراکتر است. از نظر اهمیت با هر کاراکتر دیگری برابر است.**
181181
182-
We can't add or remove spaces from a regular expression and expect it to work the same.
183182
184-
In other words, in a regular expression all characters matter, spaces too.
183+
ما نمی‌ توانیم فاصله‌ها را از یک عبارت باقاعده اضافه یا حذف کنیم و انتظار داشته باشیم که به همان صورت عمل کند.
184+
185+
به عبارت دیگر، در یک عبارت باقاعده، همه کاراکترها مهم هستند. فضاها نیز همین طور.
185186
````
186187

187188
## خلاصه

0 commit comments

Comments
 (0)