Skip to content

Commit 52f4ae1

Browse files
committed
translate alternation_or
1 parent 10910e1 commit 52f4ae1

File tree

9 files changed

+88
-88
lines changed

9 files changed

+88
-88
lines changed

Diff for: 9-regular-expressions/13-regexp-alternation/01-find-programming-language/solution.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
The first idea can be to list the languages with `|` in-between.
2+
আমরা ল্যাংগুয়েজগুলোকে অল্টারনেশন `|` দ্বারা আলাদা আলাদা লিখতে পারি।
33

4-
But that doesn't work right:
4+
কিন্তু এটি কাজ করবে না:
55

66
```js run
77
let regexp = /Java|JavaScript|PHP|C|C\+\+/g;
@@ -11,18 +11,18 @@ let str = "Java, JavaScript, PHP, C, C++";
1111
alert( str.match(regexp) ); // Java,Java,PHP,C,C
1212
```
1313

14-
The regular expression engine looks for alternations one-by-one. That is: first it checks if we have `match:Java`, otherwise -- looks for `match:JavaScript` and so on.
14+
অল্টারনেশনের সময় রেগুলার এক্সপ্রেশন ইঞ্জিন এক এক করে খুঁজে। অর্থাৎ: প্রথমত এটি `match:Java` চেক করবে, যদি না মিলে এরপর `match:JavaScript` এভাবে চলতে থাকে।
1515

16-
As a result, `match:JavaScript` can never be found, just because `match:Java` is checked first.
16+
যার ফলে, `match:JavaScript` কখনোই খুঁজে পাবে না, কেননা এটি শুরুতেই `match:Java` এর সাথে মিল হয়।
1717

18-
The same with `match:C` and `match:C++`.
18+
অনুরূপভাবে `match:C` এবং `match:C++`
1919

20-
There are two solutions for that problem:
20+
এ সমস্যার দুটি সমাধান আছে:
2121

22-
1. Change the order to check the longer match first: `pattern:JavaScript|Java|C\+\+|C|PHP`.
23-
2. Merge variants with the same start: `pattern:Java(Script)?|C(\+\+)?|PHP`.
22+
১. আমাদের প্যাটার্নটিকে এভাবে সাজিয়ে: `pattern:JavaScript|Java|C\+\+|C|PHP`
23+
২. অথবা একই নামগুলোর জন্য অপশনাল গ্রুপ মার্জ করে: `pattern:Java(Script)?|C(\+\+)?|PHP`
2424

25-
In action:
25+
যেমন:
2626

2727
```js run
2828
let regexp = /Java(Script)?|C(\+\+)?|PHP/g;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Find programming languages
1+
# প্রোগ্রামিং ল্যাংগুয়েজ অনুসন্ধান
22

3-
There are many programming languages, for instance Java, JavaScript, PHP, C, C++.
3+
বর্তমানে অনেক প্রোগ্রামিং ল্যাংগুয়েজ আছে, যেমন Java, JavaScript, PHP, C, C++
44

5-
Create a regexp that finds them in the string `subject:Java JavaScript PHP C++ C`:
5+
একটি রেগুলার এক্সপ্রেশন লিখুন যা দ্বারা এদের খুঁজে পাওয়া যায় `subject:Java JavaScript PHP C++ C`:
66

77
```js
8-
let regexp = /your regexp/g;
8+
let regexp = /আপনার প্যাটার্ন/g;
99

1010
alert("Java JavaScript PHP C++ C".match(regexp)); // Java JavaScript PHP C++ C
1111
```

Diff for: 9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/solution.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
Opening tag is `pattern:\[(b|url|quote)\]`.
2+
শুরুর ট্যাগটি হবে `pattern:\[(b|url|quote)\]`
33

4-
Then to find everything till the closing tag -- let's use the pattern `pattern:.*?` with flag `pattern:s` to match any character including the newline and then add a backreference to the closing tag.
4+
তারপর ট্যাগটি শেষ হওয়ার পূর্ব পর্যন্ত সকল কন্টেন্ট পেতে এটি `pattern:.*?` লিখি এবং নতুন লাইন সহ সকল ক্যারাক্টারের জন্য এই ফ্ল্যাগটি `pattern:s` ব্যবহার করি, অতঃপর শেষ ট্যাগটি লিখার জন্য ব্যাকরেফারেন্স ব্যবহার করি।
55

6-
The full pattern: `pattern:\[(b|url|quote)\].*?\[/\1\]`.
6+
সম্পূর্ন প্যাটার্নটি হবে: `pattern:\[(b|url|quote)\].*?\[/\1\]`
77

8-
In action:
8+
যেমন:
99

1010
```js run
1111
let regexp = /\[(b|url|quote)\].*?\[\/\1\]/gs;
@@ -20,4 +20,4 @@ let str = `
2020
alert( str.match(regexp) ); // [b]hello![/b],[quote][url]http://google.com[/url][/quote]
2121
```
2222

23-
Please note that besides escaping `pattern:[` and `pattern:]`, we had to escape a slash for the closing tag `pattern:[\/\1]`, because normally the slash closes the pattern.
23+
আমরা এই বন্ধনী `pattern:[` এবং `pattern:]` এর পূর্বে ব্যাকস্ল্যাশ দ্বারা এস্কেপিং করেছি, অনুরূপভাবে শেষ ট্যাগটিকেও `pattern:[\/\1]` এস্কেপিং করা লাগবে, কেননা স্ল্যাশ দ্বারা প্যাটার্নের শেষ বুঝায়।

Diff for: 9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/task.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
# Find bbtag pairs
1+
# bbtag অনুসন্ধান
22

3-
A "bb-tag" looks like `[tag]...[/tag]`, where `tag` is one of: `b`, `url` or `quote`.
3+
"bb-tag" দেখতে এমন `[tag]...[/tag]`, যেখানে `tag` গুলো হতে পারে: `b`, `url` বা `quote`
44

5-
For instance:
5+
উদাহরণস্বরূপ:
66
```
77
[b]text[/b]
88
[url]http://google.com[/url]
99
```
1010

11-
BB-tags can be nested. But a tag can't be nested into itself, for instance:
11+
BB-tags একটার মধ্যে আরেকটা হতে পারে। কিন্তু একই ট্যাগের ভেতর নেস্টেড হবে না, যেমন:
1212

1313
```
14-
Normal:
14+
সঠিক:
1515
[url] [b]http://google.com[/b] [/url]
1616
[quote] [b]text[/b] [/quote]
1717
18-
Can't happen:
18+
ভুল:
1919
[b][b]text[/b][/b]
2020
```
2121

22-
Tags can contain line breaks, that's normal:
22+
সাধারণত ট্যাগের মধ্যে লাইন ব্রেক থাকতে পারে:
2323

2424
```
2525
[quote]
2626
[b]text[/b]
2727
[/quote]
2828
```
2929

30-
Create a regexp to find all BB-tags with their contents.
30+
একটি রেগুলার এক্সপ্রেশন লিখুন যা দ্বারা সকল BB-tags এবং এদের কন্টেন্ট খুঁজে পাওয়া যায়।
3131

32-
For instance:
32+
উদাহরণস্বরূপ:
3333

3434
```js
35-
let regexp = /your regexp/flags;
35+
let regexp = /আপনার রেগুলার এক্সপ্রেশন/ফ্ল্যাগস;
3636

3737
let str = "..[url]http://google.com[/url]..";
3838
alert( str.match(regexp) ); // [url]http://google.com[/url]
3939
```
4040

41-
If tags are nested, then we need the outer tag (if we want we can continue the search in its content):
41+
যদি ট্যাগটি নেস্টেড হয়, তবে আমরা প্যারেন্ট ট্যাগটি খুঁজব(তাহলে আমরা পরবর্তীতে এর মধ্যের কন্টেন্টগুলোতে অনুসন্ধান চালাতে পারব):
4242

4343
```js
44-
let regexp = /your regexp/flags;
44+
let regexp = /আপনার রেগুলার এক্সপ্রেশন/ফ্ল্যাগস;;
4545

4646
let str = "..[url][b]http://google.com[/b][/url]..";
4747
alert( str.match(regexp) ); // [url][b]http://google.com[/b][/url]

Diff for: 9-regular-expressions/13-regexp-alternation/03-match-quoted-string/solution.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
The solution: `pattern:/"(\\.|[^"\\])*"/g`.
1+
সমাধানটি হবে: `pattern:/"(\\.|[^"\\])*"/g`
22

3-
Step by step:
3+
ধাপে ধাপে দেখি:
44

5-
- First we look for an opening quote `pattern:"`
6-
- Then if we have a backslash `pattern:\\` (we technically have to double it in the pattern, because it is a special character, so that's a single backslash in fact), then any character is fine after it (a dot).
7-
- Otherwise we take any character except a quote (that would mean the end of the string) and a backslash (to prevent lonely backslashes, the backslash is only used with some other symbol after it): `pattern:[^"\\]`
8-
- ...And so on till the closing quote.
5+
- প্রথমে আমরা একটি শুরুর উদ্ধৃতি চিহ্নটি খুঁজব `pattern:"`
6+
- এরপর আমরা ব্যাকস্ল্যাশ খুঁজব `pattern:\\` (এজন্য আমাদের দুটি ব্যাকস্ল্যাশ দিতে হবে, কেননা এটি একটি স্পেশাল ক্যারাক্টার), এরপর যেকোন ক্যারাক্টারের জন্য(একটি ডট)।
7+
- অন্যথায় আমরা উদ্ধৃতি চিহ্ন এবং ব্যাকস্ল্যাশ ব্যতীত সকল ক্যারাক্টার নিব: `pattern:[^"\\]`
8+
- ...এবং সর্বশেষ শেষ উদ্ধৃতি চিহ্ন।
99

10-
In action:
10+
সমাধানটি হবে:
1111

1212
```js run
1313
let regexp = /"(\\.|[^"\\])*"/g;

Diff for: 9-regular-expressions/13-regexp-alternation/03-match-quoted-string/task.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# Find quoted strings
1+
# স্ট্রিংয়ে উক্তি খুঁজা
22

3-
Create a regexp to find strings in double quotes `subject:"..."`.
3+
একটি রেগুলার এক্সপ্রেশন লিখুন যা স্ট্রিংয়ে উক্তি খুঁজে `subject:"..."`
44

5-
The strings should support escaping, the same way as JavaScript strings do. For instance, quotes can be inserted as `subject:\"` a newline as `subject:\n`, and the slash itself as `subject:\\`.
5+
স্ট্রিংটি অবশ্যই জাভাস্ক্রিপ্ট স্ট্রিংয়ের মত এস্কেপিং সাপোর্ট করবে, উক্তিটির মধ্যে উদ্ধৃতি চিহ্ন `subject:\"` বা নিউলাইন ক্যারাক্টার থাকবে `subject:\n` এবং স্ল্যাশ `subject:\\` থাকবে।
66

77
```js
88
let str = "Just like \"here\".";
99
```
1010

11-
Please note, in particular, that an escaped quote `subject:\"` does not end a string.
11+
আমাদের মনে রাখা উচিত যে, উক্তির মাঝে উদ্ধৃতি চিহ্ন থাকলে `subject:\"` তা দ্বারা বুঝায় উক্তিটি শেষ হয়নি।
1212

13-
So we should search from one quote to the other ignoring escaped quotes on the way.
13+
সুতরাং অনুসন্ধানের সময় আমাদের উক্তির মাঝে এস্কেপিং উদ্ধৃতি চিহ্নগুলোও খুঁজতে হবে।
1414

15-
That's the essential part of the task, otherwise it would be trivial.
15+
এটিই আমাদের এই টাস্কের জন্য কঠিন অংশ, অন্যথায় এটি একটি সহজ টাস্ক।
1616

17-
Examples of strings to match:
17+
উদাহরণস্বরূপ এইগুলো দেখুন:
1818
```js
19-
.. *!*"test me"*/!* ..
20-
.. *!*"Say \"Hello\"!"*/!* ... (escaped quotes inside)
21-
.. *!*"\\"*/!* .. (double slash inside)
22-
.. *!*"\\ \""*/!* .. (double slash and an escaped quote inside)
19+
.. *!*"test me"*/!* ..
20+
.. *!*"Say \"Hello\"!"*/!* ... (উক্তির ভেতরে এস্কেপিং উদ্ধৃতি চিহ্ন)
21+
.. *!*"\\"*/!* .. (উক্তির ভেতরে দুটি স্ল্যাশ)
22+
.. *!*"\\ \""*/!* .. (উক্তির ভেতরে দুটি স্ল্যাশ এবং এস্কেপিং উদ্ধৃতি চিহ্ন)
2323
```
2424

25-
In JavaScript we need to double the slashes to pass them right into the string, like this:
25+
জাভাস্ক্রিপ্টে স্ট্রিংয়ের মাঝে ডাবল স্ল্যাশ এভাবে লিখতে হবে:
2626

2727
```js run
2828
let str = ' .. "test me" .. "Say \\"Hello\\"!" .. "\\\\ \\"" .. ';

Diff for: 9-regular-expressions/13-regexp-alternation/04-match-exact-tag/solution.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
The pattern start is obvious: `pattern:<style`.
2+
প্যাটার্নটি শুরু হবে: `pattern:<style`
33

4-
...But then we can't simply write `pattern:<style.*?>`, because `match:<styler>` would match it.
4+
...কিন্তু আমরা এটিকে এভাবে `pattern:<style.*?>` লিখতে পারব না, কেননা `match:<styler>` এর সাথেও মিলবে।
55

6-
We need either a space after `match:<style` and then optionally something else or the ending `match:>`.
6+
`match:<style` এর পর আমাদের একটি স্পেস লাগবে এবং এর পর তাদের অপশনাল অ্যাট্রিবিউট লাগবে এবং শেষ হবে `match:>` দ্বারা।
77

8-
In the regexp language: `pattern:<style(>|\s.*?>)`.
8+
সুতরাং প্যাটার্নটি হবে: `pattern:<style(>|\s.*?>)`
99

10-
In action:
10+
সমাধানটি হবে:
1111

1212
```js run
1313
let regexp = /<style(>|\s.*?>)/g;
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Find the full tag
1+
# সম্পূর্ন ট্যাগ অনুসন্ধান
22

3-
Write a regexp to find the tag `<style...>`. It should match the full tag: it may have no attributes `<style>` or have several of them `<style type="..." id="...">`.
3+
এই ট্যাগটি খুঁজার `<style...>` একটি রেগুলার এক্সপ্রেশন লিখুন। এটি অবশ্যই সম্পূর্ণ ট্যাগটির সাথে মিলবে: এটি অ্যাট্রিবিউট ছাড়াও হতে পারে `<style>` আবার এর একাধিক অ্যাট্রিবিউট থাকতে পারে `<style type="..." id="...">`
44

5-
...But the regexp should not match `<styler>`!
5+
...কিন্তু এটি এর সাথে `<styler>` মিলবে না!
66

7-
For instance:
7+
উদাহরণস্বরূপ:
88

99
```js
10-
let regexp = /your regexp/g;
10+
let regexp = /আপনার প্যাটার্ন/g;
1111

1212
alert( '<style> <styler> <style test="...">'.match(regexp) ); // <style>, <style test="...">
1313
```

0 commit comments

Comments
 (0)