Greedy and lazy quantifiers by SamGreenberg · Pull Request #450 · javascript-tutorial/uk.javascript.info

@SamGreenberg

@SamGreenberg

@SamGreenberg

@dolgachio

@SamGreenberg Підкажіть будь ласка, чи актуальний статус Draft для цього пулл реквеста?

@SamGreenberg

@SamGreenberg SamGreenberg changed the title Draft: Greedy and lazy quantifiers Greedy and lazy quantifiers

Aug 14, 2023

@SamGreenberg

@stas-dolgachov draft більше не актуальний

@dolgachio

dolgachio

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дякую, за чудовий переклад! Я зараз зроблю кілька невеличких правок і прийму його

: Включається знаком питання `pattern:?` після квантифікатору. Рушій намагається знайти збіг решти патерну перед кожним повторенням квантифікованого символу.

As we've seen, the lazy mode is not a "panacea" from the greedy search. An alternative is a "fine-tuned" greedy search, with exclusions, as in the pattern `pattern:"[^"]+"`.
Як бачимо, лінивий режим не є "панацеєю" від жадібного пошуку. Як альтернативу розглядають "добре налаштований" жадібний пошук, з виключенням, як в патерні `pattern:"[^"]+"`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Як бачимо, лінивий режим не є "панацеєю" від жадібного пошуку. Як альтернативу розглядають "добре налаштований" жадібний пошук, з виключенням, як в патерні `pattern:"[^"]+"`.
Як бачимо, лінивий режим не є "панацеєю" від жадібного пошуку. Як альтернативу розглядають "добре налаштований" жадібний пошук, з виключенням, як в шаблоні `pattern:"[^"]+"`.
2. Then it looks for `pattern:.*?`: takes one character (lazily!), check if there's a match for `pattern:" class="doc">` (none).
3. Then takes another character into `pattern:.*?`, and so on... until it finally reaches `match:" class="doc">`.
1. Спочатку, регулярний вираз знаходить початок посилання `match:<a href="`.
2. Далі, він шукає `pattern:.*?`: бере один символ (ліниво!), перевіряє наявність збігу для `pattern:" class="doc">` (нема).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2. Далі, він шукає `pattern:.*?`: бере один символ (ліниво!), перевіряє наявність збігу для `pattern:" class="doc">` (нема).
2. Далі, він шукає `pattern:.*?`: бере один символ (ліниво!), перевіряє наявність збігу для `pattern:" class="doc">` (немає).
Lazy
: Enabled by the question mark `pattern:?` after the quantifier. The regexp engine tries to match the rest of the pattern before each repetition of the quantified character.
Лінивий
: Включається знаком питання `pattern:?` після квантифікатору. Рушій намагається знайти збіг решти патерну перед кожним повторенням квантифікованого символу.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: Включається знаком питання `pattern:?` після квантифікатору. Рушій намагається знайти збіг решти патерну перед кожним повторенням квантифікованого символу.
: Включається знаком питання `pattern:?` після квантифікатору. Рушій намагається знайти збіг решти шаблону перед кожним повторенням квантифікованого символу.

@javascript-translate-bot

Thank you 💖 I updated the Progress Issue #1 🎉 🎉 🎉