diff --git a/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/solution.md b/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/solution.md index 85c7748f7..5d02d6e2c 100644 --- a/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/solution.md +++ b/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/solution.md @@ -1,11 +1,11 @@ -Answers: **no, yes**. +Відповідь: **ні, так**. -- In the script `subject:Java` it doesn't match anything, because `pattern:[^script]` means "any character except given ones". So the regexp looks for `"Java"` followed by one such symbol, but there's a string end, no symbols after it. +- В скрипті `subject:Java` немає співпадінь, оскільки `pattern:[^script]` означає "пошук будь-яких символів окрім заданих". Тож регулярний вираз шукає `"Java"` за яким слідує один такий символ, але це кінець рядку і далі немає символів. ```js run alert( "Java".match(/Java[^script]/) ); // null ``` -- Yes, because the `pattern:[^script]` part matches the character `"S"`. It's not one of `pattern:script`. As the regexp is case-sensitive (no `pattern:i` flag), it treats `"S"` as a different character from `"s"`. +- Так, оскільки частина патерну `pattern:[^script]` співпадає з символом `"S"`. Його немає в переліку `pattern:script`. Бо регулярний вираз розрізняє регістри букв (не вказаний прапорець `pattern:i`), то для нього `"S"`та `"s"` це різні символи. ```js run alert( "JavaScript".match(/Java[^script]/) ); // "JavaS" diff --git a/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/task.md b/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/task.md index 5a48e01e7..88d4d9781 100644 --- a/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/task.md +++ b/9-regular-expressions/08-regexp-character-sets-and-ranges/1-find-range-1/task.md @@ -1,5 +1,5 @@ # Java[^script] -We have a regexp `pattern:/Java[^script]/`. +У нас є регулярний вираз `pattern:/Java[^script]/`. -Does it match anything in the string `subject:Java`? In the string `subject:JavaScript`? +Чи знайде він співпадіння у рядку `subject:Java`? А у рядку `subject:JavaScript`? diff --git a/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/solution.md b/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/solution.md index 69ade1b19..f93cce12f 100644 --- a/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/solution.md +++ b/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/solution.md @@ -1,8 +1,8 @@ -Answer: `pattern:\d\d[-:]\d\d`. +Відповідь: `pattern:\d\d[-:]\d\d`. ```js run let regexp = /\d\d[-:]\d\d/g; -alert( "Breakfast at 09:00. Dinner at 21-30".match(regexp) ); // 09:00, 21-30 +alert( "Сніданок о 09:00. Вечеря о 21-30".match(regexp) ); // 09:00, 21-30 ``` -Please note that the dash `pattern:'-'` has a special meaning in square brackets, but only between other characters, not when it's in the beginning or at the end, so we don't need to escape it. +Зверніть увагу, що риска `pattern:'-'` має спеціальне значення у квадратних дужках але тільки між іншими символами, не на початку чи в кінці виразу, тож немає необхідності її екранувати. diff --git a/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/task.md b/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/task.md index c8441caf4..503f2c345 100644 --- a/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/task.md +++ b/9-regular-expressions/08-regexp-character-sets-and-ranges/2-find-time-2-formats/task.md @@ -1,12 +1,12 @@ -# Find the time as hh:mm or hh-mm +# Знайдіть часовий формат hh:mm або hh-mm -The time can be in the format `hours:minutes` or `hours-minutes`. Both hours and minutes have 2 digits: `09:00` or `21-30`. +Час можна записати у форматі `години:хвилини` або `години-хвилини`. У будь-якому разі потрібні дві цифри для позначення годин і хвилин: `09:00` або `21-30`. -Write a regexp to find time: +Напишіть регулярний вираз для пошуку часового формату: ```js let regexp = /your regexp/g; -alert( "Breakfast at 09:00. Dinner at 21-30".match(regexp) ); // 09:00, 21-30 +alert( "Сніданок о 09:00. Вечеря о 21-30".match(regexp) ); // 09:00, 21-30 ``` -P.S. In this task we assume that the time is always correct, there's no need to filter out bad strings like "45:67". Later we'll deal with that too. +P.S. В цій задачі ми завжди маємо коректний час, не потрібно перевіряти неіснуючі комбінації цифр, як-то "45:67". Пізніше ми роглянемо і такі випадки. diff --git a/9-regular-expressions/08-regexp-character-sets-and-ranges/article.md b/9-regular-expressions/08-regexp-character-sets-and-ranges/article.md index a1b8f896d..8db4b9b22 100644 --- a/9-regular-expressions/08-regexp-character-sets-and-ranges/article.md +++ b/9-regular-expressions/08-regexp-character-sets-and-ranges/article.md @@ -1,169 +1,169 @@ -# Sets and ranges [...] +# Набори та діапазони [...] -Several characters or character classes inside square brackets `[…]` mean to "search for any character among given". +Декільки символів, або класи символів всередині квадратних дужок `[…]` означають "шукати будь-який символ з-поміж заданих". -## Sets +## Набори -For instance, `pattern:[eao]` means any of the 3 characters: `'a'`, `'e'`, or `'o'`. +До прикладу, `pattern:[eao]` означає будь-який з трьох символів: `'a'`, `'e'`, or `'o'`. -That's called a *set*. Sets can be used in a regexp along with regular characters: +У такий спосіб записується так званий *набір*. Набір може використовуватись в регулярних виразах разом зі звичайними символами: ```js run -// find [t or m], and then "op" +// знайти [t або m], а потім "op" alert( "Mop top".match(/[tm]op/gi) ); // "Mop", "top" ``` -Please note that although there are multiple characters in the set, they correspond to exactly one character in the match. +Зверніть увагу, що незважаючи на те, що в наборі вказано два символи, в результаті є співпадіння лише по одному з них. -So the example below gives no matches: +Тож нижченаведений приклад не знайде співпадінь: ```js run -// find "V", then [o or i], then "la" +// знайти "V", потім [o чи i], потім "la" alert( "Voila".match(/V[oi]la/) ); // null, no matches ``` -The pattern searches for: +Шаблон шукає: - `pattern:V`, -- then *one* of the letters `pattern:[oi]`, -- then `pattern:la`. +- потім *одна* з літер набору `pattern:[oi]`, +- потім `pattern:la`. -So there would be a match for `match:Vola` or `match:Vila`. +Результатом такого пошуку могли б стати варіанти `match:Vola` або `match:Vila`. -## Ranges +## Діапазони -Square brackets may also contain *character ranges*. +Квадратні дужки також можуть містити *діапазони символів*. -For instance, `pattern:[a-z]` is a character in range from `a` to `z`, and `pattern:[0-5]` is a digit from `0` to `5`. +До прикладу, `pattern:[a-z]` шукатиме символу в діапазоні від `a` до `z`, а `pattern:[0-5]` дорівнює цифрам в діапазоні від `0` до `5`. -In the example below we're searching for `"x"` followed by two digits or letters from `A` to `F`: +В нижченаведеному прикладі ми шукатимемо літеру `"x"` за якою слідують дві цифри, або літери від `A` до `F`: ```js run alert( "Exception 0xAF".match(/x[0-9A-F][0-9A-F]/g) ); // xAF ``` -Here `pattern:[0-9A-F]` has two ranges: it searches for a character that is either a digit from `0` to `9` or a letter from `A` to `F`. +Тут `pattern:[0-9A-F]` має в собі одразу два діапазони: він шукає символ, який є або цифрою від `0` до `9` , або літерою від `A` до `F`. -If we'd like to look for lowercase letters as well, we can add the range `a-f`: `pattern:[0-9A-Fa-f]`. Or add the flag `pattern:i`. +Якби ми захотіли шукати літери не тільки верхнього, а й нижнього регістру, ми могли б додати діапазон `a-f`: `pattern:[0-9A-Fa-f]`. Або додати флаг `pattern:i`. -We can also use character classes inside `[…]`. +Крім того, всередині `[…]` ми можемо використовувати символьні класи. -For instance, if we'd like to look for a wordly character `pattern:\w` or a hyphen `pattern:-`, then the set is `pattern:[\w-]`. +До прикладу, якщо ми захочемо знайти символ "слова" `pattern:\w` , або дефіс `pattern:-`, набір виглядатиме наступним чином `pattern:[\w-]`. -Combining multiple classes is also possible, e.g. `pattern:[\s\d]` means "a space character or a digit". +Комбінувати декілька класів теж можливо, наприклад `pattern:[\s\d]` означає "пробіл, або цифра". -```smart header="Character classes are shorthands for certain character sets" -For instance: +```smart header="Символьні класи це лише скорочення для деяких наборів символів" +До прикладу: -- **\d** -- is the same as `pattern:[0-9]`, -- **\w** -- is the same as `pattern:[a-zA-Z0-9_]`, -- **\s** -- is the same as `pattern:[\t\n\v\f\r ]`, plus few other rare Unicode space characters. +- **\d** -- це те саме, що й `pattern:[0-9]`, +- **\w** -- це те саме, що й `pattern:[a-zA-Z0-9_]`, +- **\s** -- це те саме, що й `pattern:[\t\n\v\f\r ]`, плюс декілька інших рідкісних пробільних символів Unicode. ``` -### Example: multi-language \w +### Приклад: \w в інших мовах світу -As the character class `pattern:\w` is a shorthand for `pattern:[a-zA-Z0-9_]`, it can't find Chinese hieroglyphs, Cyrillic letters, etc. +Оскільки символьний клас `pattern:\w` це лише скорочений запис `pattern:[a-zA-Z0-9_]`, він не зможе знайти китайські ієрогліфи, літери кирилицею тощо. -We can write a more universal pattern, that looks for wordly characters in any language. That's easy with Unicode properties: `pattern:[\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}]`. +Існує спосіб написати більш універсальний шаблон, що включатиме в себе буквенні символи будь-якої мови світу. Це легко реалізувати завдяки властивостям Unicode: `pattern:[\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}]`. -Let's decipher it. Similar to `pattern:\w`, we're making a set of our own that includes characters with following Unicode properties: +Давайте розшифруємо цей шаблон. Подібно до `pattern:\w`, ми створюємо свій діапазон, який включає в себе символи з наступними властивостями Unicode: -- `Alphabetic` (`Alpha`) - for letters, -- `Mark` (`M`) - for accents, -- `Decimal_Number` (`Nd`) - for digits, -- `Connector_Punctuation` (`Pc`) - for the underscore `'_'` and similar characters, -- `Join_Control` (`Join_C`) - two special codes `200c` and `200d`, used in ligatures, e.g. in Arabic. +- `Alphabetic` (`Alpha`) - для літер, +- `Mark` (`M`) - для акцентів, +- `Decimal_Number` (`Nd`) - для цифр, +- `Connector_Punctuation` (`Pc`) - для нижнього підкреслення `'_'` і тому подібних символів, +- `Join_Control` (`Join_C`) - два спеціальних коди `200c` та `200d`, які використовуються у лігатурах, зокрема в арабській мові. -An example of use: +Шаблон в дії: ```js run let regexp = /[\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}]/gu; let str = `Hi 你好 12`; -// finds all letters and digits: +// знайти всі літери та цифри: alert( str.match(regexp) ); // H,i,你,好,1,2 ``` -Of course, we can edit this pattern: add Unicode properties or remove them. Unicode properties are covered in more details in the article . +Звичайно, ми можемо редагувати вищенаведений шаблон: додавати Unicode властивості, або видаляти їх. Дізнатись більше про Unicode властивості можна за посиланням . -```warn header="Unicode properties aren't supported in IE" -Unicode properties `pattern:p{…}` are not implemented in IE. If we really need them, we can use library [XRegExp](http://xregexp.com/). +```warn header="Internet Explorer не підтримує Unicode властивості" +Unicode властивості `pattern:p{…}` недоступні у Internet Explorer. Втім, якщо вони нам все ж потрібні, ми можемо скористатись бібліотекою [XRegExp](http://xregexp.com/). -Or just use ranges of characters in a language that interests us, e.g. `pattern:[а-я]` for Cyrillic letters. +або просто вказати діапазон потрібних нам символів певною мовою, наприклад `pattern:[а-я]` для літер кирилицею. ``` -## Excluding ranges +## Діапазони виключень -Besides normal ranges, there are "excluding" ranges that look like `pattern:[^…]`. +Окрім звичайних діапазонів, існують діапазони "виключень" які виглядають наступним чином: `pattern:[^…]`. -They are denoted by a caret character `^` at the start and match any character *except the given ones*. +Вони відрізняються символом каретки `^` на початку і знаходять будь-який символ *окрім вказаних в діапазоні*. -For instance: +До прикладу: -- `pattern:[^aeyo]` -- any character except `'a'`, `'e'`, `'y'` or `'o'`. -- `pattern:[^0-9]` -- any character except a digit, the same as `pattern:\D`. -- `pattern:[^\s]` -- any non-space character, same as `\S`. +- `pattern:[^aeyo]` -- будь-який символ окрім `'a'`, `'e'`, `'y'` or `'o'`. +- `pattern:[^0-9]` -- будь-який символ окрім цифр, так само як і `pattern:\D`. +- `pattern:[^\s]` -- будь-який не пробільний символ `\S`. -The example below looks for any characters except letters, digits and spaces: +Нижченаведений приклад шукає будь-який символ окрім літер латиницею, цифр та пробільних символів: ```js run -alert( "alice15@gmail.com".match(/[^\d\sA-Z]/gi) ); // @ and . +alert( "alice15@gmail.com".match(/[^\d\sA-Z]/gi) ); // @ та . ``` -## Escaping in […] +## Екранування всередині […] -Usually when we want to find exactly a special character, we need to escape it like `pattern:\.`. And if we need a backslash, then we use `pattern:\\`, and so on. +Зазвичай, коли ми хочемо знайти один зі спецсимволів, нам потрібно екранувати його наступним чином `pattern:\.`. Тобто, якщо нам потрібна зворотня коса риска, ми маємо писати `pattern:\\`, і так далі. -In square brackets we can use the vast majority of special characters without escaping: +В квадратних дужках ми можемо використовувати велику кількість спецсимволів без екранування: -- Symbols `pattern:. + ( )` never need escaping. -- A hyphen `pattern:-` is not escaped in the beginning or the end (where it does not define a range). -- A caret `pattern:^` is only escaped in the beginning (where it means exclusion). -- The closing square bracket `pattern:]` is always escaped (if we need to look for that symbol). +- Символ `pattern:. + ( )` не потребує екранування. +- Дефіс `pattern:-` не потребує екранування на початку, або в кінці (тобто коли не може означати діапазон). +- Каретка `pattern:^` екранується лише на початку (без екранування означає набір символів-виключень). +- Закриваюча квадратна дужка `pattern:]` завжди потребує екранування (у випадках, коли нам потрібно знайти цей символ). -In other words, all special characters are allowed without escaping, except when they mean something for square brackets. +Інакше кажучи, всі спецсимволи можна використовувати без екранування тоді, коли вони не мають додаткового значення в квадратних дужках. -A dot `.` inside square brackets means just a dot. The pattern `pattern:[.,]` would look for one of characters: either a dot or a comma. +Крапка `.` всередині квадратних дужок означає просто крапку. Шаблон `pattern:[.,]` шукатиме на один з двох символів, або крапку, або кому. -In the example below the regexp `pattern:[-().^+]` looks for one of the characters `-().^+`: +В нижченаведеному прикладі регулярний вираз `pattern:[-().^+]` шукає один з вказаних символів `-().^+`: ```js run -// No need to escape +// Не потрібно екранувати let regexp = /[-().^+]/g; -alert( "1 + 2 - 3".match(regexp) ); // Matches +, - +alert( "1 + 2 - 3".match(regexp) ); // Знаходить +, - ``` -...But if you decide to escape them "just in case", then there would be no harm: +...Але якщо ви вирішите все ж таки екранувати їх, "про всяк випадок", гірше від того не буде: ```js run -// Escaped everything +// Всі символи екрановані let regexp = /[\-\(\)\.\^\+]/g; -alert( "1 + 2 - 3".match(regexp) ); // also works: +, - +alert( "1 + 2 - 3".match(regexp) ); // так само находить: +, - ``` -## Ranges and flag "u" +## Діапазони і прапорець "u" -If there are surrogate pairs in the set, flag `pattern:u` is required for them to work correctly. +Якщо в діапазоні є сурогатні пари, для коректної роботи регулярного виразу, прапорець `pattern:u` є обов'язковим. -For instance, let's look for `pattern:[𝒳𝒴]` in the string `subject:𝒳`: +До прикладу, давайте знайдемо `pattern:[𝒳𝒴]` у рядку `subject:𝒳`: ```js run -alert( '𝒳'.match(/[𝒳𝒴]/) ); // shows a strange character, like [?] -// (the search was performed incorrectly, half-character returned) +alert( '𝒳'.match(/[𝒳𝒴]/) ); // виводить дивний символ, схожий на [?] +// (пошук було виконано некореткно, повернуто тільки половину символу) ``` -The result is incorrect, because by default regular expressions "don't know" about surrogate pairs. +Результат є некоректним, оскільки типово регулярні вирази "не знають" про сурогатні пари. -The regular expression engine thinks that `[𝒳𝒴]` -- are not two, but four characters: -1. left half of `𝒳` `(1)`, -2. right half of `𝒳` `(2)`, -3. left half of `𝒴` `(3)`, -4. right half of `𝒴` `(4)`. +Регулярний вираз сприймає `[𝒳𝒴]` -- не як два, а як чотири символи: +1. ліва половина `𝒳` `(1)`, +2. права половина `𝒳` `(2)`, +3. ліва половина `𝒴` `(3)`, +4. права половина `𝒴` `(4)`. -We can see their codes like this: +Якщо вивести їх кодове значення ми побачимо наступне: ```js run for(let i=0; i<'𝒳𝒴'.length; i++) { @@ -171,27 +171,27 @@ for(let i=0; i<'𝒳𝒴'.length; i++) { }; ``` -So, the example above finds and shows the left half of `𝒳`. +Отже, вищенаведений приклад знайшов і вивів ліву половину `𝒳`. -If we add flag `pattern:u`, then the behavior will be correct: +Якщо ми додамо прапорець `pattern:u`, то поведінка буде коректною: ```js run alert( '𝒳'.match(/[𝒳𝒴]/u) ); // 𝒳 ``` -The similar situation occurs when looking for a range, such as `[𝒳-𝒴]`. +Подібна ситуація складається коли ми шукаємо в діапазоні, наприклад `[𝒳-𝒴]`. -If we forget to add flag `pattern:u`, there will be an error: +Якщо ми забудемо додати прапорець `pattern:u`, то отримаємо помилку: ```js run '𝒳'.match(/[𝒳-𝒴]/); // Error: Invalid regular expression ``` -The reason is that without flag `pattern:u` surrogate pairs are perceived as two characters, so `[𝒳-𝒴]` is interpreted as `[<55349><56499>-<55349><56500>]` (every surrogate pair is replaced with its codes). Now it's easy to see that the range `56499-55349` is invalid: its starting code `56499` is greater than the end `55349`. That's the formal reason for the error. +Причина в тому, що без прапорцю `pattern:u` сурогатні пари сприймаються як два окремих символи, тобто `[𝒳-𝒴]` обробляються як `[<55349><56499>-<55349><56500>]` (кожна сурогатна пара замінюється на набір кодів). Таким чином, ми бачимо, що діапазон `56499-55349` є некоректним: його початковий номер `56499` більший за останній `55349`. Це і є причиною помилки. -With the flag `pattern:u` the pattern works correctly: +З прапорцем `pattern:u` шаблон працює коректно: ```js run -// look for characters from 𝒳 to 𝒵 +// шукає символи від 𝒳 до 𝒵 alert( '𝒴'.match(/[𝒳-𝒵]/u) ); // 𝒴 ``` diff --git a/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/solution.md b/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/solution.md index 21b8762ec..bdbb48f16 100644 --- a/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/solution.md +++ b/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/solution.md @@ -1,9 +1,9 @@ -Solution: +Відповідь: ```js run let regexp = /\.{3,}/g; -alert( "Hello!... How goes?.....".match(regexp) ); // ..., ..... +alert( "Привіт!... Як справи?.....".match(regexp) ); // ..., ..... ``` -Please note that the dot is a special character, so we have to escape it and insert as `\.`. +Зауважте, що крапка це спецсимвол, тож потребує екранування за допомогою `\.`. diff --git a/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/task.md b/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/task.md index 4140b4a98..f2e32a839 100644 --- a/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/task.md +++ b/9-regular-expressions/09-regexp-quantifiers/1-find-text-manydots/task.md @@ -2,13 +2,13 @@ importance: 5 --- -# How to find an ellipsis "..." ? +# Як знайти розділовий знак три крапки "..." ? -Create a regexp to find ellipsis: 3 (or more?) dots in a row. +Створіть регулярний вираз, який знайде розділовий знак три крапки: 3 (чи навіть більше?) крапок поспіль. -Check it: +Перевірте: ```js let regexp = /your regexp/g; -alert( "Hello!... How goes?.....".match(regexp) ); // ..., ..... +alert( "Привіт!... Як справи?.....".match(regexp) ); // ..., ..... ``` diff --git a/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/solution.md b/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/solution.md index afee89c50..5526a1896 100644 --- a/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/solution.md +++ b/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/solution.md @@ -1,10 +1,10 @@ -We need to look for `#` followed by 6 hexadecimal characters. +Нам потрбіно знайти символ `#` за яким слідують 6 шістнадцяткових символів. -A hexadecimal character can be described as `pattern:[0-9a-fA-F]`. Or if we use the `pattern:i` flag, then just `pattern:[0-9a-f]`. +Шістнадцятковий символ можна описати як `pattern:[0-9a-fA-F]`. Або, якщо застосувати прапорець `pattern:i` , то запис скоротиться до `pattern:[0-9a-f]`. -Then we can look for 6 of them using the quantifier `pattern:{6}`. +Далі ми позначимо за допомогою квантифікатора, що нам потрібно саме 6 таких шістнадцяткових символів `pattern:{6}`. -As a result, we have the regexp: `pattern:/#[a-f0-9]{6}/gi`. +І у результаті, отримаємо такий регулярний вираз: `pattern:/#[a-f0-9]{6}/gi`. ```js run let regexp = /#[a-f0-9]{6}/gi; @@ -14,18 +14,18 @@ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2" alert( str.match(regexp) ); // #121212,#AA00ef ``` -The problem is that it finds the color in longer sequences: +Проблема в тому, що вищевказаний регулярний вираз знаходитиме код кольору навіть у довших послідовностях. ```js run alert( "#12345678".match( /#[a-f0-9]{6}/gi ) ) // #123456 ``` -To fix that, we can add `pattern:\b` to the end: +Щоб виправити це, ми додамо `pattern:\b` у кінці виразу: ```js run -// color +// колір alert( "#123456".match( /#[a-f0-9]{6}\b/gi ) ); // #123456 -// not a color +// не колір alert( "#12345678".match( /#[a-f0-9]{6}\b/gi ) ); // null ``` diff --git a/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/task.md b/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/task.md index 9a1923a7e..d932c2984 100644 --- a/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/task.md +++ b/9-regular-expressions/09-regexp-quantifiers/2-find-html-colors-6hex/task.md @@ -1,15 +1,15 @@ -# Regexp for HTML colors +# Регулярний вираз для кольорів в HTML -Create a regexp to search HTML-colors written as `#ABCDEF`: first `#` and then 6 hexadecimal characters. +Створіть регулярний вираз, який шукає HTML-кольори записані у форматі `#ABCDEF`: спершу символ `#` за яким слідують 6 шістнадцяткових символів. -An example of use: +Приклад використання: ```js -let regexp = /...your regexp.../ +let regexp = /...ваш регулярний вираз.../ let str = "color:#121212; background-color:#AA00ef bad-colors:f#fddee #fd2 #12345678"; alert( str.match(regexp) ) // #121212,#AA00ef ``` -P.S. In this task we do not need other color formats like `#123` or `rgb(1,2,3)` etc. +P.S. В цій задачі нам не потрібно враховувати інші формати запису кольорів, як наприклад `#123` або `rgb(1,2,3)` тощо. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy