- Notifications
You must be signed in to change notification settings - Fork179
Capturing groups#441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
dolgachio merged 2 commits intojavascript-tutorial:masterfromSamGreenberg:capturing-groupsMar 25, 2023
Uh oh!
There was an error while loading.Please reload this page.
Merged
Capturing groups#441
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
16 changes: 8 additions & 8 deletions9-regular-expressions/11-regexp-groups/01-test-mac/solution.md
This file contains hidden or 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 @@ | ||
Двоцифрове шістнадцяткове число можна записати як`pattern:[0-9a-f]{2}`(припустивши, що задано прапорець`pattern:i`). | ||
Нам потрібно число`NN`,а за ним`:NN`, повторене 5разів (більше чисел); | ||
Регулярний вираз: `pattern:[0-9a-f]{2}(:[0-9a-f]{2}){5}` | ||
Тепер продемонструємо, що збіг має захоплювати весь текст: з самого початку до самого кінця. Робиться це через огортання виразу в `pattern:^...$`. | ||
В підсумку: | ||
```js run | ||
let regexp = /^[0-9a-f]{2}(:[0-9a-f]{2}){5}$/i; | ||
alert( regexp.test('01:32:54:67:89:AB') ); // true | ||
alert( regexp.test('0132546789AB') ); // false (без двокрапок) | ||
alert( regexp.test('01:32:54:67:89') ); // false (5чисел, має бути 6) | ||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZв кінці) | ||
``` |
18 changes: 9 additions & 9 deletions9-regular-expressions/11-regexp-groups/01-test-mac/task.md
This file contains hidden or 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 @@ | ||
#Перевірити MAC-адресу | ||
[MAC-адреса](https://uk.wikipedia.org/wiki/MAC-адреса) мережевого інтерфейсу складається з 6 двоцифрових шістнадцяткових чисел, розділених двокрапкою. | ||
Наприклад: `subject:'01:32:54:67:89:AB'`. | ||
Напишіть регулярний вираз, який перевіряє, чи є рядокMAC-адресою. | ||
Приклад використання: | ||
```js | ||
let regexp = /ваш регулярний вираз/; | ||
alert( regexp.test('01:32:54:67:89:AB') ); // true | ||
alert( regexp.test('0132546789AB') ); // false (без двокрапок) | ||
alert( regexp.test('01:32:54:67:89') ); // false (5чисел, має бути 6) | ||
alert( regexp.test('01:32:54:67:89:ZZ') ) // false (ZZв кінці) | ||
``` |
12 changes: 6 additions & 6 deletions9-regular-expressions/11-regexp-groups/02-find-webcolor-3-or-6/solution.md
This file contains hidden or 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 deletions9-regular-expressions/11-regexp-groups/02-find-webcolor-3-or-6/task.md
This file contains hidden or 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 @@ | ||
#Знайти колір у форматі#abcабо #abcdef | ||
Напишіть регулярний вираз, що знаходить збіг по кольорам у форматі`#abc`або `#abcdef`.Формула є наступною: `#`, за яким знаходяться 3 або 6шістнадцяткових цифр. | ||
Приклад використання: | ||
```js | ||
let regexp = /ваш регулярний вираз/g; | ||
let str = "color: #3f3; background-color: #AA00ef; and: #abcd"; | ||
alert( str.match(regexp) ); // #3f3 #AA00ef | ||
``` | ||
P.S.Має бути саме 3 або 6шістнадцяткових цифр. Значення з 4цифрами, такі як `#abcd`,не мають рахуватись за збіг. |
4 changes: 2 additions & 2 deletions9-regular-expressions/11-regexp-groups/03-find-decimal-numbers/solution.md
This file contains hidden or 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 deletions9-regular-expressions/11-regexp-groups/03-find-decimal-numbers/task.md
This file contains hidden or 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
44 changes: 22 additions & 22 deletions9-regular-expressions/11-regexp-groups/04-parse-expression/solution.md
This file contains hidden or 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 deletions9-regular-expressions/11-regexp-groups/04-parse-expression/task.md
This file contains hidden or 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.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.