- Notifications
You must be signed in to change notification settings - Fork179
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
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
18 changes: 9 additions & 9 deletions...ular-expressions/13-regexp-alternation/01-find-programming-language/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
6 changes: 3 additions & 3 deletions9-regular-expressions/13-regexp-alternation/01-find-programming-language/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
10 changes: 5 additions & 5 deletions9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/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
30 changes: 15 additions & 15 deletions9-regular-expressions/13-regexp-alternation/02-find-matching-bbtags/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
18 changes: 9 additions & 9 deletions9-regular-expressions/13-regexp-alternation/03-match-quoted-string/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,17 +1,17 @@ | ||
Рішення: `pattern:/"(\\.|[^"\\])*"/g`. | ||
Крок за кроком: | ||
-Спочатку шукаємо відкриваючі лапки `pattern:"` | ||
-Потім, якщо є зворотній слеш`pattern:\\` (ми повинні подвоїти його у виразі, тому що це спеціальний символ),то після нього також підійде будь-який символ (крапка). | ||
-В іншому випадку, беремо будь-який символ, крім лапок (це означало б кінець рядка) та зворотнього слешу (щоб запобігти поодиноким зворотнім слешам, бо вони використовуються тільки з іншими символами після них): `pattern:[^"\\]` | ||
- ...І так далі, до закриваючих лапок. | ||
У дії: | ||
```js run | ||
let regexp = /"(\\.|[^"\\])*"/g; | ||
let str = ' .. "протестуй мене" .. "Скажи \\"Привіт\\"!" .. "\\\\ \\"" .. '; | ||
alert( str.match(regexp) ); // "протестуй мене","Скажи \"Привіт\"!","\\ \"" | ||
``` |
32 changes: 16 additions & 16 deletions9-regular-expressions/13-regexp-alternation/03-match-quoted-string/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,32 +1,32 @@ | ||
#Знайдіть рядки у лапках | ||
Створіть регулярний вираз для пошуку рядків у подвійних лапках `subject:"..."`. | ||
Рядки повинні підтримувати екранування за допомогою зворотнього слеша, аналогічно з рядками в JavaScript. Наприклад, лапки можуть бути вставлені як `subject:\"`, новий рядок як `subject:\n`,та сам зворотній слеш як `subject:\\`. | ||
```js | ||
let str = "Як ось \"тут\"."; | ||
``` | ||
Зокрема, зверніть увагу, що екрановані лапки`subject:\"`не завершують рядок. | ||
Тому нам необхідно шукати від одних лапок до інших, ігноруючи екрановані лапки на нашому шляху. | ||
У цьому і полягає основна складність завдання, адже без цієї умови -- рішення було б елементарним. | ||
Приклади відповідних рядків: | ||
```js | ||
.. *!*"протестуй мене"*/!* .. | ||
.. *!*"Скажи \"Привіт\"!"*/!* ... (екрановані рядки всередині) | ||
.. *!*"\\"*/!* .. (подвійний слеш всередині) | ||
.. *!*"\\ \""*/!* .. (подвійний слеш та екрановані лапки всередині) | ||
``` | ||
У JavaScriptнам потрібно подвоювати слеші, щоб передати їх в рядок, як тут: | ||
```js run | ||
let str = ' .. "протестуй мене" .. "Скажи \\"Привіт\\"!" .. "\\\\ \\"" .. '; | ||
//Рядок у пам’яті | ||
alert(str); // .. "протестуй мене" .. "Скажи \"Привіт\"!" .. "\\ \"" .. | ||
``` |
10 changes: 5 additions & 5 deletions9-regular-expressions/13-regexp-alternation/04-match-exact-tag/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/13-regexp-alternation/04-match-exact-tag/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,13 +1,13 @@ | ||
#Знайдіть цілий тег | ||
Напишіть регулярний вираз, який шукає тег`<style...>`.Шаблон має шукати цілий тег: він може як і не мати атрибутів`<style>`, так і мати їх декілька `<style type="..." id="...">`. | ||
...Проте регулярний вираз не повинен знаходити `<styler>`! | ||
Наприклад: | ||
```js | ||
let regexp = /ваш регулярний вираз/g; | ||
alert( '<style> <styler> <style test="...">'.match(regexp) ); // <style>, <style test="..."> | ||
``` |
60 changes: 30 additions & 30 deletions9-regular-expressions/13-regexp-alternation/article.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
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.