|
1 | | -# Patterns and flags |
| 1 | +# الگو ها و پرچم ها (Patterns and flags) |
2 | 2 |
|
3 | | -Regular expressions are patterns that provide a powerful way to search and replace in text. |
| 3 | +عبارات باقاعده(Regular expressions) الگوهایی هستند که روشی قدرتمند برای جستجو و جایگزینی در متن ارائه می دهند. |
4 | 4 |
|
5 | | -In JavaScript, they are available via the [RegExp](mdn:js/RegExp) object, as well as being integrated in methods of strings. |
| 5 | +در جاوا اسکریپت، آنها از طریق شیء [RegExp](mdn:js/RegExp) و همچنین به خوبی با متد های رشته ها ادغام می شوند. |
6 | 6 |
|
7 | | -## Regular Expressions |
| 7 | +## عبارات باقاعده (Regular Expressions) |
8 | 8 |
|
9 | | -A regular expression (also "regexp", or just "reg") consists of a *pattern* and optional *flags*. |
| 9 | +عبارت باقاعده (همچنین "regexp"، یا فقط "reg") از یک *الگو(pattern)* و *پرچم(flags)* های اختیاری تشکیل شده است. |
10 | 10 |
|
11 | | -There are two syntaxes that can be used to create a regular expression object. |
| 11 | +دو سینتکس وجود دارد که می توان از آنها برای ایجاد یک شیء عبارت باقاعده(Regular expression) استفاده کرد. |
12 | 12 |
|
13 | | -The "long" syntax: |
| 13 | +سینتکس "طولانی": |
14 | 14 |
|
15 | 15 | ```js |
16 | | -regexp = new RegExp("pattern", "flags"); |
| 16 | +regexp = new RegExp("pattern(الگو)", "flags(پرچم)"); |
17 | 17 | ``` |
18 | 18 |
|
19 | | -And the "short" one, using slashes `"/"`: |
| 19 | +و سینتکس "کوتاه" نیز، استفاده از اسلش `"/"` می باشد. |
20 | 20 |
|
21 | 21 | ```js |
22 | | -regexp = /pattern/; // no flags |
23 | | -regexp = /pattern/gmi; // with flags g,m and i (to be covered soon) |
| 22 | +regexp = /pattern/; // بدون پرچم |
| 23 | +regexp = /pattern/gmi; // با پرچم g, m, i (به زودی پوشش داده میشود) |
24 | 24 | ``` |
25 | 25 |
|
26 | | -Slashes `pattern:/.../` tell JavaScript that we are creating a regular expression. They play the same role as quotes for strings. |
| 26 | +اسلش های `pattern:/.../` به جاوا اسکریپت می گوید که ما در حال ایجاد یک عبارت باقاعده هستیم. آنها همان نقش کوتیشن("") را برای رشته ها بازی می کنند. |
27 | 27 |
|
28 | 28 | In both cases `regexp` becomes an instance of the built-in `RegExp` class. |
29 | 29 |
|
|
0 commit comments