Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d9ab4cf

Browse files
authored
👾 smth
1 parent 61888a2 commit d9ab4cf

File tree

1 file changed

+4
-4
lines changed
  • 9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head

1 file changed

+4
-4
lines changed

‎9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/solution.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
In order to insert after the `<body>` tag, we must first find it. We can use the regular expression pattern `pattern:<body.*?>` for that.
22

3-
In this task we don't need to modify the `<body>` tag. We only need to add the text after it.
3+
In this task, we don't need to modify the `<body>` tag. We only need to add the text after it.
44

55
Here's how we can do it:
66

@@ -27,10 +27,10 @@ As you can see, there's only lookbehind part in this regexp.
2727
It works like this:
2828
- At every position in the text.
2929
- Check if it's preceded by `pattern:<body.*?>`.
30-
- If it's so then we have the match.
30+
- If it's so, then we have the match.
3131

32-
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.*?>`.
32+
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.*?>`.
3333

34-
So it replaces the "empty line", preceeded by `pattern:<body.*?>`, with `<h1>Hello</h1>`. That's the insertion after `<body>`.
34+
So it replaces the "empty line", preceded by `pattern:<body.*?>`, with `<h1>Hello</h1>`. That's the insertion after `<body>`.
3535

3636
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.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /