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
We need to look for `#`followed by 6 hexadecimal characters.
1
+
আমাদের `#`এর পর ৬টি হেক্সাডেসিমেল ক্যারাক্টার খোঁজা লাগবে।
2
2
3
-
A hexadecimal character can be described as `pattern:[0-9a-fA-F]`. Or if we use the `pattern:i`flag, then just `pattern:[0-9a-f]`.
3
+
`pattern:[0-9a-fA-F]` এর মাধ্যমে আমরা হেক্সাডেসিমেল ক্যারাক্টার সংজ্ঞায়িত করতে পারি। অথবা যদি আমরা `pattern:i`ফ্ল্যাগ ব্যবহার করি তাহলে প্যাটার্নটি হবে `pattern:[0-9a-f]`।
4
4
5
-
Then we can look for 6 of them using the quantifier `pattern:{6}`.
5
+
এখন আমরা কোয়ান্টিফায়ার `pattern:{6}` ব্যবহার করে ৬টি ক্যারাক্টার খুঁজতে পারি।
6
6
7
-
As a result, we have the regexp: `pattern:/#[a-f0-9]{6}/gi`.
Let's say we have a string like `+7(903)-123-45-67`and want to find all numbers in it. But unlike before, we are interested not in single digits, but full numbers: `7, 903, 123, 45, 67`.
3
+
এখন মনে করন আমাদের এমন একটি `+7(903)-123-45-67`স্ট্রিং আছে এবং আমরা এর সকল নাম্বার খুঁজে পেতে চাই। কিন্ত পূর্বের মত, আমরা একক অঙ্ক চাই না, পূর্ণ সংখ্যাগুলো চাই: `7, 903, 123, 45, 67`।
4
4
5
-
A number is a sequence of 1 or more digits `pattern:\d`. To mark how many we need, we can append a *quantifier*.
5
+
সংখ্যা হল এক বা একাধিক অঙ্কের একটি সমষ্টি `pattern:\d`। আমাদের প্রয়োজনমত অঙ্কের জন্য আমরা *quantifier* সংযোজন করতে পারি।
6
6
7
-
## Quantity {n}
7
+
## সংখ্যা {n}
8
8
9
-
The simplest quantifier is a number in curly braces: `pattern:{n}`.
9
+
সবচেয়ে সহজ কোয়ান্টিফায়ার হল দ্বিতীয় বন্ধনীর মধ্যে একটি সংখ্যা: `pattern:{n}`।
10
10
11
-
A quantifier is appended to a character (or a character class, or a `[...]`set etc) and specifies how many we need.
11
+
কোয়ান্টিফায়ারে যেকোন ধরণের ক্যারাক্টার (অথবা ক্যারাক্টার ক্লাস, অথবা `[...]`সেট ইত্যাদি) আমাদের প্রয়োজনমত সংযোজন করতে পারি।
12
12
13
-
It has a few advanced forms, let's see examples:
13
+
এটি ব্যবহারের বিভিন্ন উপায় আছে, চলুন কয়েকটি উদাহরণ দেখি:
14
14
15
-
The exact count: `pattern:{5}`
16
-
: `pattern:\d{5}`denotes exactly 5 digits, the same as `pattern:\d\d\d\d\d`.
15
+
নির্দিষ্ট সংখ্যা গণনা: `pattern:{5}`
16
+
: `pattern:\d{5}`এটি দ্বারা ৫টি অঙ্ক বুঝায়, যা `pattern:\d\d\d\d\d` এর অনুরূপ।
17
17
18
-
The example below looks for a 5-digit number:
18
+
নিচের উদাহরণে একটি ৫ অঙ্কের সংখ্যা খোঁজা হচ্ছে:
19
19
20
20
```js run
21
21
alert( "I'm 12345 years old".match(/\d{5}/) ); // "12345"
22
22
```
23
23
24
-
We can add `\b` to exclude longer numbers: `pattern:\b\d{5}\b`.
24
+
আমরা `\b` যুক্ত করে এর চেয়ে বড় অঙ্কের সংখ্যাগুলো বাদ দিতে পারি: `pattern:\b\d{5}\b`।
25
25
26
-
The range: `pattern:{3,5}`, match 3-5 times
27
-
: To find numbers from 3 to 5 digits we can put the limits into curly braces: `pattern:\d{3,5}`
26
+
রেঞ্জ: `pattern:{3,5}`, ৩-৫ অঙ্কের সংখ্যার সাথে মিল খুঁজে
27
+
: ৩ থেকে ৫ অঙ্কের মধ্যের সংখ্যা গুলো খুঁজতে আমরা দ্বিতীয় বন্ধনীতে সীমা নির্ধারণ করে দিতে পারি: `pattern:\d{3,5}`
28
28
29
29
```js run
30
30
alert( "I'm not 12, but 1234 years old".match(/\d{3,5}/) ); // "1234"
31
31
```
32
32
33
-
We can omit the upper limit.
33
+
আমরা সর্বোচ্চ সীমাটি বাদ দিতে পারি।
34
34
35
-
Then a regexp `pattern:\d{3,}` looks for sequences of digits of length `3` or more:
35
+
এ রেগুলার এক্সপ্রেশনটি `pattern:\d{3,}` ৩ বা ততোধিক অঙ্কের মিল গুলো খোঁজে:
36
36
37
37
```js run
38
38
alert( "I'm not 12, but 345678 years old".match(/\d{3,}/) ); // "345678"
39
39
```
40
40
41
-
Let's return to the string `+7(903)-123-45-67`.
41
+
এখন আমাদের পূর্বের `+7(903)-123-45-67` স্ট্রিংটি দেখি।
42
42
43
-
A number is a sequence of one or more digits in a row. So the regexp is`pattern:\d{1,}`:
43
+
সংখ্যা হল এক বা একাধিক অঙ্কের সমষ্টি। সুতরাং রেগুলার এক্সপ্রেশনটি হবে`pattern:\d{1,}`:
44
44
45
45
```js run
46
46
let str ="+7(903)-123-45-67";
@@ -50,14 +50,14 @@ let numbers = str.match(/\d{1,}/g);
50
50
alert(numbers); // 7,903,123,45,67
51
51
```
52
52
53
-
## Shorthands
53
+
## সংক্ষিপ্তরূপ
54
54
55
-
There are shorthands for most used quantifiers:
55
+
কোয়ান্টিফায়ারের কিছু সংক্ষিপ্তরূপ আছে:
56
56
57
57
`pattern:+`
58
-
: Means "one or more", the same as `pattern:{1,}`.
58
+
: এটি দ্বারা বুঝায় "এক বা ততোধিক", এটি `pattern:{1,}` এর অনুরূপ।
59
59
60
-
For instance, `pattern:\d+` looks for numbers:
60
+
উদাহরণস্বরূপ, `pattern:\d+` প্যাটার্নটি দ্বারা সংখ্যা খোঁজা হয়:
61
61
62
62
```js run
63
63
let str = "+7(903)-123-45-67";
@@ -66,11 +66,11 @@ There are shorthands for most used quantifiers:
66
66
```
67
67
68
68
`pattern:?`
69
-
: Means "zero or one", the same as `pattern:{0,1}`. In other words, it makes the symbol optional.
69
+
: এটি দ্বারা বুঝায় "শূন্য বা এক", এটি `pattern:{0,1}` এর অনুরূপ। অন্যথায় বলা যায়, এটি ঐচ্ছিক কোয়ান্টিফায়ার।
70
70
71
-
For instance, the pattern `pattern:ou?r` looks for `match:o` followed by zero or one `match:u`, and then `match:r`.
71
+
উদাহরণস্বরূপ, `pattern:ou?r` প্যাটার্নটি `match:o` এর পর শূন্য বা একটি `match:u` এর খুঁজ করে, এবং তারপর `match:r` এর সাথে মিল খুঁজে।
72
72
73
-
So, `pattern:colou?r` finds both `match:color` and `match:colour`:
73
+
সুতরাং, `pattern:colou?r` প্যাটার্নটি দ্বারা `match:color` এবং `match:colour` উভয়ের সাথে মিল হবে:
74
74
75
75
```js run
76
76
let str = "Should I write color or colour?";
@@ -79,64 +79,64 @@ There are shorthands for most used quantifiers:
79
79
```
80
80
81
81
`pattern:*`
82
-
: Means "zero or more", the same as `pattern:{0,}`. That is, the character may repeat any times or be absent.
82
+
: এটি দ্বারা বুঝায় "শূন্য বা ততোধিক", এটি `pattern:{0,}` এর অনুরূপ। অন্যথায় বলা যায়, ক্যারাক্টারটি একাধিকও থাকতে পারে অথবা নাও থাকতে পারে।
83
83
84
-
For example, `pattern:\d0*` looks for a digit followed by any number of zeroes (may be many or none):
84
+
উদাহরণস্বরূপ, `pattern:\d0*` প্যাটার্নটি দ্বারা শূন্যের খুঁজ করে (একাধিকও থাকতে পারে অথবা নাও থাকতে পারে):
85
85
86
86
```js run
87
87
alert( "100 10 1".match(/\d0*/g) ); // 100, 10, 1
88
88
```
89
89
90
-
Compare it with `pattern:+` (one or more):
90
+
চলুন একে `pattern:+` এর সাথে তুলনা করে দেখি (এক বা ততোধিক):
91
91
92
92
```js run
93
93
alert( "100 10 1".match(/\d0+/g) ); // 100, 10
94
-
// 1 not matched, as 0+ requires at least one zero
94
+
// 1 এর সাথে মিল পায়নি, যেহেতু 0+ দ্বারা অন্তত একটি শূন্য থাকতে হবে বুঝায়
95
95
```
96
96
97
-
## More examples
97
+
## আরো কিছু উদাহরণ
98
98
99
-
Quantifiers are used very often. They serve as the main "building block" of complex regular expressions, so let's see more examples.
99
+
রেগুলার এক্সপ্রেশনে আমরা প্রায় কোয়ান্টিফায়ার ব্যবহার করি। এরা জটিল রেগুলার এক্সপ্রেশনে প্রধান "বিল্ডিং ব্লক" হিসেবে কাজ করে, চলুন কিছু উদাহরণ দেখি।
100
100
101
-
**Regexp for decimal fractions (a number with a floating point): `pattern:\d+\.\d+`**
101
+
**দশমিক ভগ্নাংশের জন্য রেগুলার এক্সপ্রেশন (দশমিক সহ সংখ্যা): `pattern:\d+\.\d+`**
**Regexp "opening or closing HTML-tag without attributes":`pattern:/<\/?[a-z][a-z0-9]*>/i`**
126
+
**"অ্যাট্রিবিউট ছাড়া শুরুর এবং শেষের এইচটিএমএল ট্যাগ" এর জন্য রেগুলার এক্সপ্রেশন:`pattern:/<\/?[a-z][a-z0-9]*>/i`**
127
127
128
-
We added an optional slash `pattern:/?`near the beginning of the pattern. Had to escape it with a backslash, otherwise JavaScript would think it is the pattern end.
128
+
আমরা প্যাটার্নের শুরুতে একটি ঐচ্ছিক স্লাশ `pattern:/?`দিয়ে শুরু করেছি। এটি ব্যাকস্লাশ দিয়ে বাদ দিতে হবে, অন্যথায় জাভাস্ক্রিপ্ট ইঞ্জিন প্যাটার্ন শেষ হিসেবে ধরে নিবে।
```smart header="To make a regexp more precise, we often need make it more complex"
135
-
We can see one common rule in these examples: the more precise is the regular expression -- the longer and more complex it is.
134
+
```smart header="একটি রেগুলার এক্সপ্রেশন কে যথাযথ ব্যবহার করতে, আমরা প্রায় এটিকে জটিল করে তৈরি করি"
135
+
আমরা এই উদাহরণগুলোতে একটি সাধারন নিয়ম দেখতে পারছি: রেগুলার এক্সপ্রেশনটি আরো সুনির্দিষ্ট হচ্ছে -- দীর্ঘতর এবং আরো জটিল হচ্ছে।
136
136
137
-
For instance, for HTML tags we could use a simpler regexp: `pattern:<\w+>`. But as HTML has stricter restrictions for a tag name, `pattern:<[a-z][a-z0-9]*>`is more reliable.
137
+
উদাহরণস্বরূপ, এইচটিএমএল ট্যাগের জন্য আমরা সহজ এই রেগুলার এক্সপ্রেশনটি: `pattern:<\w+>` ব্যবহার করতে পারি। কিন্তু এইচটিএমএল ট্যাগের নামানুসারে আমরা এই `pattern:<[a-z][a-z0-9]*>`প্যাটার্নটি আরো পঠনযোগ্য করতে পারি।
138
138
139
-
Can we use`pattern:<\w+>`or we need `pattern:<[a-z][a-z0-9]*>`?
139
+
আমরা কি এটি`pattern:<\w+>`অথবা এটি `pattern:<[a-z][a-z0-9]*>` ব্যবহার করতে পারি?
140
140
141
-
In real life both variants are acceptable. Depends on how tolerant we can be to "extra" matches and whether it's difficult or not to remove them from the result by other means.
141
+
বাস্তবক্ষেত্রে দুটিই ব্যবহারযোগ্য। এটি নির্ভর করে আমরা কিভাবে "অতিরিক্ত" মিলগুলো ব্যবহার করব এবং অন্যান্য ক্ষেত্রে মিল গুলো থেকে কিভাবে তাদের বাদ দিব তার উপর নির্ভর করে।
0 commit comments