Skip to content

Commit 67e6072

Browse files
translate replace part
1 parent f6422d4 commit 67e6072

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

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

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ let regexp = new RegExp(`<${tag}>`); // مانند /<h2>/ اگر در اعلان
123123
}
124124
```
125125

126-
## Replacing: str.replace
126+
## جایگزین کردن: str.replace
127127

128-
The method `str.replace(regexp, replacement)` replaces matches found using `regexp` in string `str` with `replacement` (all matches if there's flag `pattern:g`, otherwise, only the first one).
128+
روش `str.replace(regexp، replacement)` تطابق ‌هایی را که با استفاده از `regexp` در رشته `str` یافت می‌شود را با `replacement` جایگزین می‌کند (همه منطبق هستند اگر پرچم `pattern:g` وجود داشته باشد، در غیر این صورت، فقط اولین مورد است).
129129

130-
For instance:
130+
برای مثال:
131131

132132
```js run
133133
// no flag g
@@ -137,18 +137,18 @@ alert( "We will, we will".replace(/we/i, "I") ); // I will, we will
137137
alert( "We will, we will".replace(/we/ig, "I") ); // I will, I will
138138
```
139139

140-
The second argument is the `replacement` string. We can use special character combinations in it to insert fragments of the match:
140+
آرگومان دوم رشته، `replacement(جایگزینی)` است. می‌توانیم از ترکیب کاراکتر های ویژه در آن برای درج قطعاتی از تطابق استفاده کنیم:
141141

142-
| Symbols | Action in the replacement string |
142+
| نماد | عمل در رشته جایگزین |
143143
|--------|--------|
144-
|`$&`|inserts the whole match|
145-
|<code>$&#096;</code>|inserts a part of the string before the match|
146-
|`$'`|inserts a part of the string after the match|
147-
|`$n`|if `n` is a 1-2 digit number, then it inserts the contents of n-th parentheses, more about it in the chapter <info:regexp-groups>|
148-
|`$<name>`|inserts the contents of the parentheses with the given `name`, more about it in the chapter <info:regexp-groups>|
149-
|`$$`|inserts character `$` |
150-
151-
An example with `pattern:$&`:
144+
|`$&`|کل تطابق را درج می کند|
145+
|<code>$&#096;</code>|قسمتی از رشته را قبل از تطابق وارد می کند|
146+
|`$'`|قسمتی از رشته را بعد از تطابق وارد می کند|
147+
|`$n`|اگر`n` یک عدد 1-2 رقمی باشد، محتویات پرانتزهای n را درج می کند، اطلاعات بیشتر در مورد آن در فصل <info:regexp-groups>|
148+
|`$<name>`|محتویات پرانتز را با `name` داده شده درج می کند، اطلاعات بیشتر در مورد آن در فصل <info:regexp-groups>|
149+
|`$$`|کاراکتر "$" را درج می کند |
150+
151+
مثالی برای `pattern:$&`:
152152

153153
```js run
154154
alert( "I love HTML".replace(/HTML/, "$& and JavaScript") ); // I love HTML and JavaScript

0 commit comments

Comments
 (0)