GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Alternation (OR) | by vladiuskor · Pull Request #388 · javascript-tutorial/uk.javascript.info Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
| # Альтернація (АБО) | | ||
|
|
||
| Alternation is the term in regular expression that is actually a simple "OR". | ||
| Альтернація - це термін у регулярному виразі, який насправді є простим "АБО". |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Альтернація - це термін у регулярному виразі, який насправді є простим "АБО". | |
| Альтернація -- це термін у регулярному виразі, який насправді є простим "АБО". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| - `pattern:gr(a|e)y` means exactly the same as `pattern:gr[ae]y`. | ||
| - `pattern:gra|ey` means `match:gra` or `match:ey`. | ||
| - `pattern:gr(a|e)y` означає те саме, що і `pattern:gr[ae]y`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| - `pattern:gr(a|e)y` означає те саме, що і `pattern:gr[ae]y`. | |
| - `pattern:gr(a|e)y` означає те саме, що й `pattern:gr[ae]y`. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| To apply alternation to a chosen part of the pattern, we can enclose it in parentheses: | ||
| - `pattern:I love HTML|CSS` matches `match:I love HTML` or `match:CSS`. | ||
| - `pattern:I love (HTML|CSS)` matches `match:I love HTML` or `match:I love CSS`. | ||
| Для того, щоб використати альтернацію до обраної частини шаблону, ми можемо загорнути його у дужки: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Для того, щоб використати альтернацію до обраної частини шаблону, ми можемо загорнути його у дужки: | |
| Для того, щоб використати альтернацію з обраною частиною шаблону, ми можемо загорнути його у дужки: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ## Приклад: регулярний вираз для часу | ||
|
|
||
| In previous articles there was a task to build a regexp for searching time in the form `hh:mm`, for instance `12:00`. But a simple `pattern:\d\d:\d\d` is too vague. It accepts `25:99` as the time (as 99 minutes match the pattern, but that time is invalid). | ||
| У попередніх главах було завдання написати регулярний вираз для пошуку часу у форматі `гг:хх`, наприклад `12:00`. Однак простий шаблон `pattern:\d\d:\d\d` недостатньо точний. Він приймає `25:99` як час (99 хвилин підходять до шаблону, однак цей час не є вірним). |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| У попередніх главах було завдання написати регулярний вираз для пошуку часу у форматі `гг:хх`, наприклад `12:00`. Однак простий шаблон `pattern:\d\d:\d\d` недостатньо точний. Він приймає `25:99` як час (99 хвилин підходять до шаблону, однак цей час не є вірним). | |
| У попередніх статтях було завдання написати регулярний вираз для пошуку часу у форматі `гг:хх`, наприклад `12:00`. Однак простий шаблон `pattern:\d\d:\d\d` недостатньо точний. Він приймає `25:99` як час (99 хвилин підходять до шаблону, однак цей час не є вірним). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| - (no other first digit is allowed) | ||
| - Якщо перша цифра `0` або `1`, тоді наступна може бути будь-якою цифрою: `pattern:[01]\d`. | ||
| - В іншому випадку, якщо перша цифра `2`, тоді наступна має бути від 0 до 3 `pattern:[0-3]`. | ||
| - (іншої першої цифри не може бути) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| - (іншої першої цифри не може бути) | |
| - (іншої першої цифри бути не може) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| ```js | ||
| let regexp = /your regexp/flags; | ||
| let regexp = /ваш регулярний вираз/прапорець; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| let regexp = /ваш регулярний вираз/прапорець; | |
| let regexp = /ваш регулярний вираз/прапорці; |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ``` | ||
|
|
||
| If tags are nested, then we need the outer tag (if we want we can continue the search in its content): | ||
| Якщо теки вкладені, тоді необхідно шукати зовнішній тег (за бажанням, можна продовжити пошук всередині його вмісту): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Якщо теки вкладені, тоді необхідно шукати зовнішній тег (за бажанням, можна продовжити пошук всередині його вмісту): | |
| Якщо теги вкладені, тоді необхідно шукати зовнішній тег (за бажанням, можна продовжити пошук всередині його вмісту): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| ```js | ||
| let regexp = /your regexp/flags; | ||
| let regexp = /ваш регулярний вираз/прапорець; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| let regexp = /ваш регулярний вираз/прапорець; | |
| let regexp = /ваш регулярний вираз/прапорці; |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -1,17 +1,17 @@ | |||
| The solution: `pattern:/"(\\.|[^"\\])*"/g`. | |||
| Вирішення: `pattern:/"(\\.|[^"\\])*"/g`. | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| Вирішення: `pattern:/"(\\.|[^"\\])*"/g`. | |
| Рішення: `pattern:/"(\\.|[^"\\])*"/g`. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Тому нам необхідно шукати від одних лапок до інших, ігноруючи екрановані лапки на нашому шляху. | ||
|
|
||
| That's the essential part of the task, otherwise it would be trivial. | ||
| У цьому і полягає основна складність завдання, адже без цієї умови - вирішення було б елементарним. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| У цьому і полягає основна складність завдання, адже без цієї умови - вирішення було б елементарним. | |
| У цьому і полягає основна складність завдання, адже без цієї умови -- рішення було б елементарним. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please make the requested changes. After it, add a comment "/done". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/done |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Дякую за можливість зробити внесок у розвиток чудового ресурсу для україномовної спільноти. Згідний з усіма правками.) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@all-contributors add @vladiuskor for translation |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@stas-dolgachov I've put up a pull request to add @vladiuskor! 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.