-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from msisaifu/capturing-groups
Capturing groups
- Loading branch information
Showing
9 changed files
with
178 additions
and
178 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
9-regular-expressions/11-regexp-groups/01-test-mac/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
A two-digit hex number is `pattern:[0-9a-f]{2}` (assuming the flag `pattern:i` is set). | ||
একটি দুই অঙ্কবিশিষ্ট হেক্সাডেসিমেল নাম্বারের প্যাটার্ন হল `pattern:[0-9a-f]{2}` (ধরে নিই, `pattern:i` ফ্ল্যাগ সেট আছে)। | ||
|
||
We need that number `NN`, and then `:NN` repeated 5 times (more numbers); | ||
সুতরাং আমাদের এই নাম্বারটি `NN` লাগবে, এবং এটির `:NN` ৫ বার পুনরাবৃত্তি হবে; | ||
|
||
The regexp is: `pattern:[0-9a-f]{2}(:[0-9a-f]{2}){5}` | ||
সুতরাং রেগুলার এক্সপ্রেশনটি হবে: `pattern:[0-9a-f]{2}(:[0-9a-f]{2}){5}` | ||
|
||
Now let's show that the match should capture all the text: start at the beginning and end at the end. That's done by wrapping the pattern in `pattern:^...$`. | ||
এখন চলুন ম্যাচটি শুরু থেকে শেষ পর্যন্ত সকল পুরো লাইনটি পাঠ করার উপযোগী করি। এজন্য সম্পূর্ন প্যাটার্নটি `pattern:^...$` এর মধ্যে লিখি। | ||
|
||
Finally: | ||
শেষ পর্যন্ত: | ||
|
||
```js run | ||
let regexp = /^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$/i; | ||
|
||
alert( regexp.test('01:32:54:67:89:AB') ); // true | ||
alert( regexp.test('01:32:54:67:89:AB') ); // সত্য | ||
|
||
alert( regexp.test('0132546789AB') ); // false (no colons) | ||
alert( regexp.test('0132546789AB') ); // মিথ্যা (কোলন নেয়) | ||
|
||
alert( regexp.test('01:32:54:67:89') ); // false (5 numbers, need 6) | ||
alert( regexp.test('01:32:54:67:89') ); // মিথ্যা (৫টি নাম্বার, অবশ্যই ৬টি হতে হবে) | ||
|
||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZ in the end) | ||
alert( regexp.test('01:32:54:67:89:ZZ') ) // মিথ্যা (শেষে ZZ) | ||
``` |
20 changes: 10 additions & 10 deletions
20
9-regular-expressions/11-regexp-groups/01-test-mac/task.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# Check MAC-address | ||
# MAC-address যাচাই | ||
|
||
[MAC-address](https://en.wikipedia.org/wiki/MAC_address) of a network interface consists of 6 two-digit hex numbers separated by a colon. | ||
[MAC-address](https://en.wikipedia.org/wiki/MAC_address) হল নেটওয়ার্ক ইন্টারফেসের ৬ টি দুই অঙ্কবিশিষ্ট একটি হেক্সাডেসিমেল নাম্বার যা কোলন দ্বারা পৃথক থাকে। | ||
|
||
For instance: `subject:'01:32:54:67:89:AB'`. | ||
যেমন: `subject:'01:32:54:67:89:AB'`। | ||
|
||
Write a regexp that checks whether a string is MAC-address. | ||
MAC-address যাচাইয়ের জন্য একটি রেগুলার এক্সপ্রেশন লিখুন। | ||
|
||
Usage: | ||
উদাহরণস্বরুপ: | ||
```js | ||
let regexp = /your regexp/; | ||
let regexp = /আপনার প্যাটার্ন লিখুন/; | ||
|
||
alert( regexp.test('01:32:54:67:89:AB') ); // true | ||
alert( regexp.test('01:32:54:67:89:AB') ); // সত্য | ||
|
||
alert( regexp.test('0132546789AB') ); // false (no colons) | ||
alert( regexp.test('0132546789AB') ); // মিথ্যা (কোলন নেয়) | ||
|
||
alert( regexp.test('01:32:54:67:89') ); // false (5 numbers, must be 6) | ||
alert( regexp.test('01:32:54:67:89') ); // মিথ্যা (৫টি নাম্বার, অবশ্যই ৬টি হতে হবে) | ||
|
||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZ ad the end) | ||
alert( regexp.test('01:32:54:67:89:ZZ') ) // মিথ্যা (শেষে ZZ) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
9-regular-expressions/11-regexp-groups/02-find-webcolor-3-or-6/task.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# Find color in the format #abc or #abcdef | ||
# এই কালার ফরম্যাটগুলো খুঁজুন #abc বা #abcdef | ||
|
||
Write a RegExp that matches colors in the format `#abc` or `#abcdef`. That is: `#` followed by 3 or 6 hexadecimal digits. | ||
একটি রেগুলার এক্সপ্রেশন লিখুন যা এই দুটি কালার ফরম্যাটের সাথে ম্যাচ করবে `#abc` বা `#abcdef`। এটি হবে: `#` দ্বারা ৩ বা ৬ অঙ্কের হেক্সাডেসিমেল নাম্বার। | ||
|
||
Usage example: | ||
উদাহরণস্বরুপ: | ||
```js | ||
let regexp = /your regexp/g; | ||
let regexp = /আপনার প্যাটার্ন লিখুন/g; | ||
|
||
let str = "color: #3f3; background-color: #AA00ef; and: #abcd"; | ||
|
||
alert( str.match(regexp) ); // #3f3 #AA00ef | ||
``` | ||
|
||
P.S. This should be exactly 3 or 6 hex digits. Values with 4 digits, such as `#abcd`, should not match. | ||
বি.দ্র. এটি অবশ্যই ৩ বা ৬ অঙ্কের হেক্সাডেসিমেল নাম্বার হতে হবে। যেমন, ৪ অঙ্কের সাথে `#abcd` এরা মিলবে না। |
4 changes: 2 additions & 2 deletions
4
9-regular-expressions/11-regexp-groups/03-find-decimal-numbers/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
9-regular-expressions/11-regexp-groups/03-find-decimal-numbers/task.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 23 additions & 22 deletions
45
9-regular-expressions/11-regexp-groups/04-parse-expression/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
9-regular-expressions/11-regexp-groups/04-parse-expression/task.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.