diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md index 980a7fe665..fffada1888 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md @@ -1,9 +1,8 @@ +In order to insert after the `` tag, you must first find it. We will use the regular expression pattern `pattern:`. -Для того, чтобы вставить после тега ``, нужно вначале его найти. Будем использовать регулярное выражение `pattern:`. +Next, we need to leave the `` tag in place and add text after it. -Далее, нам нужно оставить сам тег `` на месте и добавить текст после него. - -Это можно сделать вот так: +This can be done like this: ```js run let str = '......'; str = str.replace(//, '$&

Hello

'); @@ -11,9 +10,9 @@ str = str.replace(//, '$&

Hello

'); alert(str); // ...

Hello

... ``` -В строке замены `$&` означает само совпадение, то есть мы заменяем `pattern:` заменяется на самого себя плюс `

Hello

`. +In the replacement string `$&` means the match itself, that is, we replace `pattern:` Is replaced by itself plus `

Hello

`. -Альтернативный вариант - использовать ретроспективную проверку: +An alternative is to use retrospective validation: ```js run let str = '......'; @@ -22,8 +21,8 @@ str = str.replace(/(?<=)/, `

Hello

`); alert(str); // ...

Hello

... ``` -Такое регулярное выражение на каждой позиции будет проверять, не идёт ли прямо перед ней `pattern:`. Если да - совпадение найдено. Но сам тег `pattern:` в совпадение не входит, он только участвует в проверке. А других символов после проверки в нём нет, так что текст совпадения будет пустым. +Such a regular expression at each position will check if `pattern:`does not go directly in front of it. If yes, a match is found. But the tag `pattern:` does not coincide, it only participates in the verification. And there are no other characters after checking in it, so the match text will be empty. -Происходит замена "пустой строки", перед которой идёт `pattern:` на `

Hello

`. Что, как раз, и есть вставка этой строки после ``. +This replaces the "empty line", followed by `pattern:` With `

Hello

`. Which, exactly, is the insertion of this line after ``. -P.S. Этому регулярному выражению не помешают флаги: `pattern://si`, чтобы в "точку" входил перевод строки (тег может занимать несколько строк), а также чтобы теги в другом регистре типа `match:` тоже находились. +P.S. The flags: `pattern://si`, will not interfere with this regular expression, so that a line break appears in the "dot" (a tag can span several lines), and also that the tags are in a different register of the `match:` type, too. diff --git a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md index ac9e5e4cee..9ecc2a7a63 100644 --- a/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md +++ b/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md @@ -1,13 +1,13 @@ -# Вставьте после фрагмента +# Insert After Head -Есть строка с HTML-документом. +There is a line with an HTML Document. -Вставьте после тега `` (у него могут быть атрибуты) строку `

Hello

`. +Insert after tag `` (it may have attributes) line `

Hello

`. -Например: +For instance: ```js -let regexp = /ваше регулярное выражение/; +let regexp = /your regular expression/; let str = ` @@ -20,7 +20,7 @@ let str = ` str = str.replace(regexp, `

Hello

`); ``` -После этого значение `str`: +After that value `str`: ```html

Hello