Skip to content

Commit fba23c0

Browse files
authored
Merge pull request #195 from msisaifu/regexp-multiline-mode
Multiline mode of anchors ^ $, flag "m"
2 parents ae9823e + 3413a23 commit fba23c0

File tree

1 file changed

+24
-24
lines changed
  • 9-regular-expressions/05-regexp-multiline-mode

1 file changed

+24
-24
lines changed
+24-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Multiline mode of anchors ^ $, flag "m"
1+
# মাল্টিলাইনে মোডে অ্যাঙ্কর ^ $ ও ফ্ল্যাগ "m"
22

3-
The multiline mode is enabled by the flag `pattern:m`.
3+
`pattern:m` ফ্ল্যাগের মাধ্যমে মাল্টিলাইন মোড এনাবল হয়।
44

5-
It only affects the behavior of `pattern:^` and `pattern:$`.
5+
এটি কেবলমাত্র `pattern:^` এবং `pattern:$` এর বিহেভিয়ারকে প্রভাবিত করে।
66

7-
In the multiline mode they match not only at the beginning and the end of the string, but also at start/end of line.
7+
মাল্টিলাইন মোডে এটি কেবল স্ট্রিং এর শুরু এবং শেষে মিল খুঁজে না, লাইনের শুরু ও শেষে-ও মিল খুঁজে।
88

9-
## Searching at line start ^
9+
## ক্যারেট চিহ্ন ^ লাইনের শুরুতে সার্চ করে
1010

11-
In the example below the text has multiple lines. The pattern `pattern:/^\d/gm` takes a digit from the beginning of each line:
11+
যেমন নিম্নোক্ত টেক্সটে মাল্টিপল লাইন আছে। প্যাটার্নটি `pattern:/^\d/gm` প্রতি লাইনের শুরুর অঙ্কটি নিবে:
1212

1313
```js run
1414
let str = `1st place: Winnie
@@ -20,7 +20,7 @@ alert( str.match(/^\d/gm) ); // 1, 2, 3
2020
*/!*
2121
```
2222

23-
Without the flag `pattern:m` only the first digit is matched:
23+
`pattern:m` ফ্ল্যাগটি ছাড়া কেবলমাত্র প্রথম অংশটি মিলবেঃ
2424

2525
```js run
2626
let str = `1st place: Winnie
@@ -32,19 +32,19 @@ alert( str.match(/^\d/g) ); // 1
3232
*/!*
3333
```
3434

35-
That's because by default a caret `pattern:^` only matches at the beginning of the text, and in the multiline mode -- at the start of any line.
35+
কেননা ক্যারেট চিহ্ন `pattern:^` ডিফল্টভাবে কেবলমাত্র টেক্সটের শুরুতে মিল খুঁজে, এবং মাল্টিলাইন মোডে -- এটি যেকোন লাইনের শুরুতে মিল খুঁজে।
3636

3737
```smart
38-
"Start of a line" formally means "immediately after a line break": the test `pattern:^` in multiline mode matches at all positions preceeded by a newline character `\n`.
38+
"লাইনের শুরু" দিয়ে বুঝায় "লাইন ব্রেকের পরপর": মাল্টিলাইন মোডে `pattern:^` লাইনের শুরু হতে নিউলাইন ক্যারাক্টারের `\n` আগ পর্যন্ত মিলে।
3939
40-
And at the text start.
40+
এবং টেক্সটের শুরু হতে।
4141
```
4242

43-
## Searching at line end $
43+
## ডলার চিহ্ন $ লাইনের শেষে সার্চ করে
4444

45-
The dollar sign `pattern:$` behaves similarly.
45+
ডলার চিহ্নও `pattern:$` একই ধরণের আচরণ করে।
4646

47-
The regular expression `pattern:\d$` finds the last digit in every line
47+
`pattern:\d$` রেগুলার এক্সপ্রেশনটি প্রতি লাইনের শেষ অংশটি খুঁজবে।
4848

4949
```js run
5050
let str = `Winnie: 1
@@ -54,21 +54,21 @@ Eeyore: 3`;
5454
alert( str.match(/\d$/gm) ); // 1,2,3
5555
```
5656

57-
Without the flag `pattern:m`, the dollar `pattern:$` would only match the end of the whole text, so only the very last digit would be found.
57+
`m` ফ্ল্যাগ ছাড়া, ডলার চিহ্ন `pattern:$` কেবলমাত্র টেক্সটের শেষে মিল খুঁজে, সুতরাং আমরা শুধু শেষের অংশটি পাবো।
5858

5959
```smart
60-
"End of a line" formally means "immediately before a line break": the test `pattern:$` in multiline mode matches at all positions succeeded by a newline character `\n`.
60+
"লাইনের শেষ" দিয়ে বুঝায় "লাইন ব্রেকের পূর্বপর্যন্ত": মাল্টিলাইন মোডে `pattern:$` নিউলাইন ক্যারাক্টারের `\n` আগ হতে শুরু করে নতুন নিউলাইন অথবা টেক্সটের শুরু পর্যন্ত মিল খুঁজে।
6161
62-
And at the text end.
62+
এবং টেক্সটের শেষ হতে।
6363
```
6464

65-
## Searching for \n instead of ^ $
65+
## ^ $ এর পরিবর্তে \n দিয়ে সার্চিং
6666

67-
To find a newline, we can use not only anchors `pattern:^` and `pattern:$`, but also the newline character `\n`.
67+
নতুন লাইন শুরু হয়েছে কিনা তা কেবল `pattern:^` এবং `pattern:$` দিয়ে জানা ছাড়াও আমরা `\n` ক্যারাক্টারও ব্যবহার করে জানতে পারি।
6868

69-
What's the difference? Let's see an example.
69+
চলুন একটা উদাহরণের মাধ্যমে পার্থক্য বুঝার চেষ্টা করি।
7070

71-
Here we search for `pattern:\d\n` instead of `pattern:\d$`:
71+
এখানে আমরা `pattern:\d$` এর পরিবর্তে `pattern:\d\n` খুঁজি:
7272

7373
```js run
7474
let str = `Winnie: 1
@@ -78,10 +78,10 @@ Eeyore: 3`;
7878
alert( str.match(/\d\n/gm) ); // 1\n,2\n
7979
```
8080

81-
As we can see, there are 2 matches instead of 3.
81+
এখানে আমরা দেখতে পাচ্ছি। ৩ টা ফলাফলের বদলে ২ টি ফলাফল পাওয়া গেছে।
8282

83-
That's because there's no newline after `subject:3` (there's text end though, so it matches `pattern:$`).
83+
কেননা `subject:3` এর পর কোন নিউলাইন নেই (যদি টেক্সট শেষও হয়ে যায়, `pattern:$` ব্যবহার করলে আমরা `subject:3`-ও পেতাম)।
8484

85-
Another difference: now every match includes a newline character `match:\n`. Unlike the anchors `pattern:^` `pattern:$`, that only test the condition (start/end of a line), `\n` is a character, so it becomes a part of the result.
85+
আরেকটি পার্থক্য: এখন পাওয়া প্রতিটি মিলে একটি নিউলাইন `match:\n` ক্যারাক্টারও অন্তর্ভুক্ত। অ্যাঙ্কর প্যাটার্নগুলো `pattern:^` `pattern:$` কেবল লাইনের শুরু আর শেষের কন্ডিশন চেক করে, যেহেতু `\n` ও একটি ক্যারাক্টার, এটিও ফলাফলের একটি অংশ হয়ে যায়।
8686

87-
So, a `\n` in the pattern is used when we need newline characters in the result, while anchors are used to find something at the beginning/end of a line.
87+
সুতরাং, আমাদের ফলাফলে যদি নিউলাইন ক্যারাক্টার প্রয়োজন হয় আমরা প্যাটার্নে `\n` ব্যবহার করি, অন্যথায় লাইনের শুরুতে বা শেষে কিছু খুঁজতে অ্যাঙ্কর ব্যবহার করি।

0 commit comments

Comments
 (0)