-
Notifications
You must be signed in to change notification settings - Fork 181
Alternation (OR) | #388
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternation (OR) | #388
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||
|
||||||
The first idea can be to list the languages with `|` in-between. | ||||||
Перше, що може прийти на думку - перерахувати мови, розділивши їх за допомогою `|`. | ||||||
|
||||||
But that doesn't work right: | ||||||
Однак, це не спрацює так, як нам потрібно: | ||||||
|
Однак, це не спрацює так, як нам потрібно: | |
Однак, це не спрацює належним чином: |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,11 +1,11 @@ | ||||||
|
||||||
Opening tag is `pattern:\[(b|url|quote)]`. | ||||||
Відкриваючий тег - це `pattern:\[(b|url|quote)]`. | ||||||
|
Відкриваючий тег - це `pattern:\[(b|url|quote)]`. | |
Відкриваючий тег -- це `pattern:\[(b|url|quote)]`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,47 +1,47 @@ | ||||||
# Find bbtag pairs | ||||||
# Знайдіть пари ВВ-кодів | ||||||
|
# Знайдіть пари ВВ-кодів | |
# Знайдіть пари ВВ-тегів |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ВВ-код має вигляд `[tag]...[/tag]`, де `tag` - це один з: `b`, `url` або `quote`. | |
ВВ-тег має вигляд `[tag]...[/tag]`, де `tag` --це один з: `b`, `url` або `quote`. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ВВ-коди можуть бути вкладеними. Але тег не може бути вкладеним сам у себе, наприклад: | |
ВВ-теги можуть бути вкладеними. Але тег не може бути вкладеним сам у себе, наприклад: |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Створіть регулярний вираз для пошуку всіх BB-кодів та їх вмісту. | |
Створіть регулярний вираз для пошуку всіх BB-тегів та їх вмісту. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let regexp = /ваш регулярний вираз/прапорець; | |
let regexp = /ваш регулярний вираз/прапорці; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Якщо теки вкладені, тоді необхідно шукати зовнішній тег (за бажанням, можна продовжити пошук всередині його вмісту): | |
Якщо теги вкладені, тоді необхідно шукати зовнішній тег (за бажанням, можна продовжити пошук всередині його вмісту): |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let regexp = /ваш регулярний вираз/прапорець; | |
let regexp = /ваш регулярний вираз/прапорці; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,17 +1,17 @@ | ||||||
The solution: `pattern:/"(\\.|[^"\\])*"/g`. | ||||||
Вирішення: `pattern:/"(\\.|[^"\\])*"/g`. | ||||||
|
Вирішення: `pattern:/"(\\.|[^"\\])*"/g`. | |
Рішення: `pattern:/"(\\.|[^"\\])*"/g`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,32 +1,32 @@ | ||||||
# 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:\\`. | ||||||
Рядки повинні підтримувати екранування за допомогою зворотнього слеша, аналогічно з рядками в JavaScript. Наприклад, лапки можуть бути вставлені як `subject:\"`, новий рядок як `subject:\n`, та сам зворотній слеш як `subject:\\`. | ||||||
|
||||||
```js | ||||||
let str = "Just like \"here\"."; | ||||||
let str = "Як ось \"тут\"."; | ||||||
``` | ||||||
|
||||||
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. | ||||||
У цьому і полягає основна складність завдання, адже без цієї умови - вирішення було б елементарним. | ||||||
|
У цьому і полягає основна складність завдання, адже без цієї умови - вирішення було б елементарним. | |
У цьому і полягає основна складність завдання, адже без цієї умови -- рішення було б елементарним. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Find the full tag | ||
# Знайдіть цілий тег | ||
|
||
Write a regexp to find the tag `<style...>`. It should match the full tag: it may have no attributes `<style>` or have several of them `<style type="..." id="...">`. | ||
Напишіть регулярний вираз, який шукає тег `<style...>`. Шаблон має шукати цілий тег: він може як і не мати атрибутів `<style>`, так і мати їх декілька `<style type="..." id="...">`. | ||
|
||
...But the regexp should not match `<styler>`! | ||
...Проте регулярний вираз не повинен знаходити `<styler>`! | ||
|
||
For instance: | ||
Наприклад: | ||
|
||
```js | ||
let regexp = /your regexp/g; | ||
let regexp = /ваш регулярний вираз/g; | ||
|
||
alert( '<style> <styler> <style test="...">'.match(regexp) ); // <style>, <style test="..."> | ||
``` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,67 +1,67 @@ | ||||||
# Alternation (OR) | | ||||||
# Альтернація (АБО) | | ||||||
|
||||||
Alternation is the term in regular expression that is actually a simple "OR". | ||||||
Альтернація - це термін у регулярному виразі, який насправді є простим "АБО". | ||||||
|
Альтернація - це термін у регулярному виразі, який насправді є простим "АБО". | |
Альтернація -- це термін у регулярному виразі, який насправді є простим "АБО". |
Outdated
There was a problem hiding this comment.
Choose a reason for 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`. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для того, щоб використати альтернацію до обраної частини шаблону, ми можемо загорнути його у дужки: | |
Для того, щоб використати альтернацію з обраною частиною шаблону, ми можемо загорнути його у дужки: |
Outdated
There was a problem hiding this comment.
Choose a reason for 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 хвилин підходять до шаблону, однак цей час не є вірним). |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (іншої першої цифри не може бути) | |
- (іншої першої цифри бути не може) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.