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
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,16 +88,15 @@ let regexp = new RegExp(`<${tag}>`); // خواهد بود /<h2>/ جواب داد
88
88
```js run
89
89
let str = "We will, we will rock you";
90
90
91
-
let result = str.match(/we/i); // without flag g
91
+
let result = str.match(/we/i); // بدون پرچم g
92
92
93
-
alert( result[0] ); // We (1st match)
93
+
alert( result[0] ); // We (اولین تطابق)
94
94
alert( result.length ); // 1
95
95
96
96
// Details:
97
97
alert( result.index ); // 0 (موقعیت تطابق)
98
98
alert( result.input ); // We will, we will rock you (رشته منبع)
99
99
```
100
-
101
100
اگر بخشی از عبارت باقاعده در داخل پرانتز قرار بگیرد، ممکن است آرایه، ایندکس های دیگری در کنار ایندکس `0` نیز داشته باشد. ما آن را در فصل <info:regexp-groups> پوشش خواهیم داد.
102
101
103
102
3. و در نهایت، اگر هیچ تطابقی وجود نداشته باشد، `null` بر می گرداند. (فرقی نمی کند که پرچم `pattern:g` وجود داشته باشد یا خیر).
@@ -108,7 +107,7 @@ let regexp = new RegExp(`<${tag}>`); // خواهد بود /<h2>/ جواب داد
108
107
let matches = "JavaScript".match(/HTML/); // = null
109
108
110
109
if (!matches.length) { // Error: Cannot read property 'length' of null
111
-
alert("Error in the line above");
110
+
alert("خطا در خط بالایی");
112
111
}
113
112
```
114
113
@@ -118,7 +117,7 @@ let regexp = new RegExp(`<${tag}>`); // خواهد بود /<h2>/ جواب داد
118
117
let matches = "JavaScript".match(/HTML/)*!* || []*/!*;
0 commit comments