Merge pull request #3040 from Rnbsov/patch-59

👾 fix typo
This commit is contained in:
Ilya Kantor 2022-06-12 23:50:58 +02:00 committed by GitHub
commit ca4c4bbec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -1,6 +1,6 @@
In order to insert after the `<body>` tag, we must first find it. We can use the regular expression pattern `pattern:<body.*?>` for that.
In this task we don't need to modify the `<body>` tag. We only need to add the text after it.
In this task, we don't need to modify the `<body>` tag. We only need to add the text after it.
Here's how we can do it:
@ -26,11 +26,11 @@ As you can see, there's only lookbehind part in this regexp.
It works like this:
- At every position in the text.
- Check if it's preceeded by `pattern:<body.*?>`.
- If it's so then we have the match.
- Check if it's preceded by `pattern:<body.*?>`.
- If it's so, then we have the match.
The tag `pattern:<body.*?>` won't be returned. The result of this regexp is literally an empty string, but it matches only at positions preceeded by `pattern:<body.*?>`.
The tag `pattern:<body.*?>` won't be returned. The result of this regexp is literally an empty string, but it matches only at positions preceded by `pattern:<body.*?>`.
So it replaces the "empty line", preceeded by `pattern:<body.*?>`, with `<h1>Hello</h1>`. That's the insertion after `<body>`.
So it replaces the "empty line", preceded by `pattern:<body.*?>`, with `<h1>Hello</h1>`. That's the insertion after `<body>`.
P.S. Regexp flags, such as `pattern:s` and `pattern:i` can also be useful: `pattern:/<body.*?>/si`. The `pattern:s` flag makes the dot `pattern:.` match a newline character, and `pattern:i` flag makes `pattern:<body>` also match `match:<BODY>` case-insensitively.

View file

@ -21,6 +21,7 @@ str = str.replace(regexp, `<h1>Hello</h1>`);
```
After that the value of `str` should be:
```html
<html>
<body style="height: 200px"><h1>Hello</h1>