en.javascript.info/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md
Lavrentiy Rubtsov fec6e3dae4
👾 smth
2022-06-07 17:53:53 +06:00

501 B

Insert After Head

We have a string with an HTML Document.

Write a regular expression that inserts <h1>Hello</h1> immediately after <body> tag. The tag may have attributes.

For instance:

let regexp = /your regular expression/;

let str = `
<html>
  <body style="height: 200px">
  ...
  </body>
</html>
`;

str = str.replace(regexp, `<h1>Hello</h1>`);

After that the value of str should be:

<html>
  <body style="height: 200px"><h1>Hello</h1>
  ...
  </body>
</html>