From 52f4ae13086fc984f21c1cb026ee08f76362d0ca Mon Sep 17 00:00:00 2001 From: Saiful Date: Fri, 15 Jan 2021 11:26:18 +0600 Subject: [PATCH] translate alternation_or --- .../01-find-programming-language/solution.md | 18 +++--- .../01-find-programming-language/task.md | 8 +-- .../02-find-matching-bbtags/solution.md | 10 ++-- .../02-find-matching-bbtags/task.md | 24 ++++---- .../03-match-quoted-string/solution.md | 14 ++--- .../03-match-quoted-string/task.md | 24 ++++---- .../04-match-exact-tag/solution.md | 10 ++-- .../04-match-exact-tag/task.md | 10 ++-- .../13-regexp-alternation/article.md | 58 +++++++++---------- 9 files changed, 88 insertions(+), 88 deletions(-) diff --git a/9-regular-expressions/13-regexp-alternation/01-find-programming-language/solution.md b/9-regular-expressions/13-regexp-alternation/01-find-programming-language/solution.md index e33f9cf2f..83056b5d8 100644 --- a/9-regular-expressions/13-regexp-alternation/01-find-programming-language/solution.md +++ b/9-regular-expressions/13-regexp-alternation/01-find-programming-language/solution.md @@ -1,7 +1,7 @@ -The first idea can be to list the languages with `|` in-between. +আমরা ল্যাংগুয়েজগুলোকে অল্টারনেশন `|` দ্বারা আলাদা আলাদা লিখতে পারি। -But that doesn't work right: +কিন্তু এটি কাজ করবে না: ```js run let regexp = /Java|JavaScript|PHP|C|C\+\+/g; @@ -11,18 +11,18 @@ let str = "Java, JavaScript, PHP, C, C++"; alert( str.match(regexp) ); // Java,Java,PHP,C,C ``` -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. +অল্টারনেশনের সময় রেগুলার এক্সপ্রেশন ইঞ্জিন এক এক করে খুঁজে। অর্থাৎ: প্রথমত এটি `match:Java` চেক করবে, যদি না মিলে এরপর `match:JavaScript` এভাবে চলতে থাকে। -As a result, `match:JavaScript` can never be found, just because `match:Java` is checked first. +যার ফলে, `match:JavaScript` কখনোই খুঁজে পাবে না, কেননা এটি শুরুতেই `match:Java` এর সাথে মিল হয়। -The same with `match:C` and `match:C++`. +অনুরূপভাবে `match:C` এবং `match:C++`। -There are two solutions for that problem: +এ সমস্যার দুটি সমাধান আছে: -1. Change the order to check the longer match first: `pattern:JavaScript|Java|C\+\+|C|PHP`. -2. Merge variants with the same start: `pattern:Java(Script)?|C(\+\+)?|PHP`. +১. আমাদের প্যাটার্নটিকে এভাবে সাজিয়ে: `pattern:JavaScript|Java|C\+\+|C|PHP`। +২. অথবা একই নামগুলোর জন্য অপশনাল গ্রুপ মার্জ করে: `pattern:Java(Script)?|C(\+\+)?|PHP`। -In action: +যেমন: ```js run let regexp = /Java(Script)?|C(\+\+)?|PHP/g; diff --git a/9-regular-expressions/13-regexp-alternation/01-find-programming-language/task.md b/9-regular-expressions/13-regexp-alternation/01-find-programming-language/task.md index e0f7af95c..0f3779da7 100644 --- a/9-regular-expressions/13-regexp-alternation/01-find-programming-language/task.md +++ b/9-regular-expressions/13-regexp-alternation/01-find-programming-language/task.md @@ -1,11 +1,11 @@ -# Find programming languages +# প্রোগ্রামিং ল্যাংগুয়েজ অনুসন্ধান -There are many programming languages, for instance Java, JavaScript, PHP, C, C++. +বর্তমানে অনেক প্রোগ্রামিং ল্যাংগুয়েজ আছে, যেমন Java, JavaScript, PHP, C, C++। -Create a regexp that finds them in the string `subject:Java JavaScript PHP C++ C`: +একটি রেগুলার এক্সপ্রেশন লিখুন যা দ্বারা এদের খুঁজে পাওয়া যায় `subject:Java JavaScript PHP C++ C`: ```js -let regexp = /your regexp/g; +let regexp = /আপনার প্যাটার্ন/g; alert("Java JavaScript PHP C++ C".match(regexp)); // Java JavaScript PHP C++ C ``` diff --git a/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/solution.md b/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/solution.md index 9b3fa1877..bb885455d 100644 --- a/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/solution.md +++ b/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/solution.md @@ -1,11 +1,11 @@ -Opening tag is `pattern:\[(b|url|quote)\]`. +শুরুর ট্যাগটি হবে `pattern:\[(b|url|quote)\]`। -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. +তারপর ট্যাগটি শেষ হওয়ার পূর্ব পর্যন্ত সকল কন্টেন্ট পেতে এটি `pattern:.*?` লিখি এবং নতুন লাইন সহ সকল ক্যারাক্টারের জন্য এই ফ্ল্যাগটি `pattern:s` ব্যবহার করি, অতঃপর শেষ ট্যাগটি লিখার জন্য ব্যাকরেফারেন্স ব্যবহার করি। -The full pattern: `pattern:\[(b|url|quote)\].*?\[/\1\]`. +সম্পূর্ন প্যাটার্নটি হবে: `pattern:\[(b|url|quote)\].*?\[/\1\]`। -In action: +যেমন: ```js run let regexp = /\[(b|url|quote)\].*?\[\/\1\]/gs; @@ -20,4 +20,4 @@ let str = ` alert( str.match(regexp) ); // [b]hello![/b],[quote][url]http://google.com[/url][/quote] ``` -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. +আমরা এই বন্ধনী `pattern:[` এবং `pattern:]` এর পূর্বে ব্যাকস্ল্যাশ দ্বারা এস্কেপিং করেছি, অনুরূপভাবে শেষ ট্যাগটিকেও `pattern:[\/\1]` এস্কেপিং করা লাগবে, কেননা স্ল্যাশ দ্বারা প্যাটার্নের শেষ বুঝায়। diff --git a/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/task.md b/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/task.md index 72d715afd..3e417da4a 100644 --- a/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/task.md +++ b/9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/task.md @@ -1,25 +1,25 @@ -# Find bbtag pairs +# bbtag অনুসন্ধান -A "bb-tag" looks like `[tag]...[/tag]`, where `tag` is one of: `b`, `url` or `quote`. +"bb-tag" দেখতে এমন `[tag]...[/tag]`, যেখানে `tag` গুলো হতে পারে: `b`, `url` বা `quote`। -For instance: +উদাহরণস্বরূপ: ``` [b]text[/b] [url]http://google.com[/url] ``` -BB-tags can be nested. But a tag can't be nested into itself, for instance: +BB-tags একটার মধ্যে আরেকটা হতে পারে। কিন্তু একই ট্যাগের ভেতর নেস্টেড হবে না, যেমন: ``` -Normal: +সঠিক: [url] [b]http://google.com[/b] [/url] [quote] [b]text[/b] [/quote] -Can't happen: +ভুল: [b][b]text[/b][/b] ``` -Tags can contain line breaks, that's normal: +সাধারণত ট্যাগের মধ্যে লাইন ব্রেক থাকতে পারে: ``` [quote] @@ -27,21 +27,21 @@ Tags can contain line breaks, that's normal: [/quote] ``` -Create a regexp to find all BB-tags with their contents. +একটি রেগুলার এক্সপ্রেশন লিখুন যা দ্বারা সকল BB-tags এবং এদের কন্টেন্ট খুঁজে পাওয়া যায়। -For instance: +উদাহরণস্বরূপ: ```js -let regexp = /your regexp/flags; +let regexp = /আপনার রেগুলার এক্সপ্রেশন/ফ্ল্যাগস; let str = "..[url]http://google.com[/url].."; alert( str.match(regexp) ); // [url]http://google.com[/url] ``` -If tags are nested, then we need the outer tag (if we want we can continue the search in its content): +যদি ট্যাগটি নেস্টেড হয়, তবে আমরা প্যারেন্ট ট্যাগটি খুঁজব(তাহলে আমরা পরবর্তীতে এর মধ্যের কন্টেন্টগুলোতে অনুসন্ধান চালাতে পারব): ```js -let regexp = /your regexp/flags; +let regexp = /আপনার রেগুলার এক্সপ্রেশন/ফ্ল্যাগস;; let str = "..[url][b]http://google.com[/b][/url].."; alert( str.match(regexp) ); // [url][b]http://google.com[/b][/url] diff --git a/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/solution.md b/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/solution.md index 5a007aee0..2c472d724 100644 --- a/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/solution.md +++ b/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/solution.md @@ -1,13 +1,13 @@ -The solution: `pattern:/"(\\.|[^"\\])*"/g`. +সমাধানটি হবে: `pattern:/"(\\.|[^"\\])*"/g`। -Step by step: +ধাপে ধাপে দেখি: -- First we look for an opening quote `pattern:"` -- 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). -- 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:[^"\\]` -- ...And so on till the closing quote. +- প্রথমে আমরা একটি শুরুর উদ্ধৃতি চিহ্নটি খুঁজব `pattern:"` +- এরপর আমরা ব্যাকস্ল্যাশ খুঁজব `pattern:\\` (এজন্য আমাদের দুটি ব্যাকস্ল্যাশ দিতে হবে, কেননা এটি একটি স্পেশাল ক্যারাক্টার), এরপর যেকোন ক্যারাক্টারের জন্য(একটি ডট)। +- অন্যথায় আমরা উদ্ধৃতি চিহ্ন এবং ব্যাকস্ল্যাশ ব্যতীত সকল ক্যারাক্টার নিব: `pattern:[^"\\]` +- ...এবং সর্বশেষ শেষ উদ্ধৃতি চিহ্ন। -In action: +সমাধানটি হবে: ```js run let regexp = /"(\\.|[^"\\])*"/g; diff --git a/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/task.md b/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/task.md index ad41d91b1..3139af64d 100644 --- a/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/task.md +++ b/9-regular-expressions/13-regexp-alternation/03-match-quoted-string/task.md @@ -1,28 +1,28 @@ -# Find quoted strings +# স্ট্রিংয়ে উক্তি খুঁজা -Create a regexp to find strings in double quotes `subject:"..."`. +একটি রেগুলার এক্সপ্রেশন লিখুন যা স্ট্রিংয়ে উক্তি খুঁজে `subject:"..."`। -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:\\`. +স্ট্রিংটি অবশ্যই জাভাস্ক্রিপ্ট স্ট্রিংয়ের মত এস্কেপিং সাপোর্ট করবে, উক্তিটির মধ্যে উদ্ধৃতি চিহ্ন `subject:\"` বা নিউলাইন ক্যারাক্টার থাকবে `subject:\n` এবং স্ল্যাশ `subject:\\` থাকবে। ```js let str = "Just like \"here\"."; ``` -Please note, in particular, that an escaped quote `subject:\"` does not end a string. +আমাদের মনে রাখা উচিত যে, উক্তির মাঝে উদ্ধৃতি চিহ্ন থাকলে `subject:\"` তা দ্বারা বুঝায় উক্তিটি শেষ হয়নি। -So we should search from one quote to the other ignoring escaped quotes on the way. +সুতরাং অনুসন্ধানের সময় আমাদের উক্তির মাঝে এস্কেপিং উদ্ধৃতি চিহ্নগুলোও খুঁজতে হবে। -That's the essential part of the task, otherwise it would be trivial. +এটিই আমাদের এই টাস্কের জন্য কঠিন অংশ, অন্যথায় এটি একটি সহজ টাস্ক। -Examples of strings to match: +উদাহরণস্বরূপ এইগুলো দেখুন: ```js -.. *!*"test me"*/!* .. -.. *!*"Say \"Hello\"!"*/!* ... (escaped quotes inside) -.. *!*"\\"*/!* .. (double slash inside) -.. *!*"\\ \""*/!* .. (double slash and an escaped quote inside) +.. *!*"test me"*/!* .. +.. *!*"Say \"Hello\"!"*/!* ... (উক্তির ভেতরে এস্কেপিং উদ্ধৃতি চিহ্ন) +.. *!*"\\"*/!* .. (উক্তির ভেতরে দুটি স্ল্যাশ) +.. *!*"\\ \""*/!* .. (উক্তির ভেতরে দুটি স্ল্যাশ এবং এস্কেপিং উদ্ধৃতি চিহ্ন) ``` -In JavaScript we need to double the slashes to pass them right into the string, like this: +জাভাস্ক্রিপ্টে স্ট্রিংয়ের মাঝে ডাবল স্ল্যাশ এভাবে লিখতে হবে: ```js run let str = ' .. "test me" .. "Say \\"Hello\\"!" .. "\\\\ \\"" .. '; diff --git a/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/solution.md b/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/solution.md index 5d4ba8d96..6f9734b41 100644 --- a/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/solution.md +++ b/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/solution.md @@ -1,13 +1,13 @@ -The pattern start is obvious: `pattern:`, because `match:` would match it. +...কিন্তু আমরা এটিকে এভাবে `pattern:` লিখতে পারব না, কেননা `match:` এর সাথেও মিলবে। -We need either a space after `match:`. +`match:` দ্বারা। -In the regexp language: `pattern:|\s.*?>)`. +সুতরাং প্যাটার্নটি হবে: `pattern:|\s.*?>)`। -In action: +সমাধানটি হবে: ```js run let regexp = /|\s.*?>)/g; diff --git a/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/task.md b/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/task.md index e8a9e31b4..9a1fbb0a5 100644 --- a/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/task.md +++ b/9-regular-expressions/13-regexp-alternation/04-match-exact-tag/task.md @@ -1,13 +1,13 @@ -# Find the full tag +# সম্পূর্ন ট্যাগ অনুসন্ধান -Write a regexp to find the tag ``. It should match the full tag: it may have no attributes `