You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 9-regular-expressions/01-regexp-introduction/article.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,18 +23,18 @@ regexp = /pattern/; // بدون پرچم
23
23
regexp =/pattern/gmi; // با پرچم g, m, i (به زودی پوشش داده میشود)
24
24
```
25
25
26
-
اسلش های `pattern:/.../` به جاوا اسکریپت می گوید که ما در حال ایجاد یک عبارت باقاعده هستیم. آنها همان نقش کوتیشن("") را برای رشته ها بازی می کنند.
26
+
اسلش های `pattern:/.../` به جاوا اسکریپت می گوید که ما در حال ایجاد یک عبارت باقاعده هستیم. آنها همان نقش کوتیشن('') را برای رشته ها بازی می کنند.
27
27
28
-
In both cases `regexp`becomes an instance of the built-in`RegExp`class.
28
+
در هر دو مورد، `regexp`به یک نمونه از کلاس داخلی`RegExp`تبدیل میشود.
29
29
30
-
The main difference between these two syntaxes is that pattern using slashes `/.../` does not allow for expressions to be inserted (like string template literals with `${...}`). They are fully static.
30
+
تفاوت اصلی بین این دو سینتکس در این است که الگو با استفاده از اسلشهای `/.../`، اجازه درج عبارات را نمی دهد (مانند حروف الفبای قالب(template literals) رشته با `${...}`). آنها کاملا ساکن هستند.
31
31
32
-
Slashes are used when we know the regular expression at the code writing time -- and that's the most common situation. While `new RegExp`is more often used when we need to create a regexp "on the fly" from a dynamically generated string. For instance:
32
+
اسلش ها زمانی استفاده می شوند که عبارت باقاعده را در زمان نوشتن کد بدانیم -- و این رایج ترین حالت است. در حالی که `new RegExp`بیشتر زمانی استفاده می شود که ما نیاز به ایجاد یک regexp "در حال پرواز" از یک رشته تولید شده به صورت پویا داشته باشیم. برای مثال:
33
33
34
34
```js
35
-
let tag =prompt("What tag do you want to find?", "h2");
35
+
let tag =prompt("چه بر چسبی می خواهید پیدا کنید؟", "h2");
36
36
37
-
let regexp =newRegExp(`<${tag}>`); //same as /<h2>/ if answered "h2" in the prompt above
37
+
let regexp =newRegExp(`<${tag}>`); //مانند /<h2>/ اگر در اعلان بالا "h2" پاسخ داده شود
0 commit comments