en.javascript.info/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md
2020-01-14 23:21:42 +05:30

441 B

Paste after fragment

There is a line with an HTML Document.

Insert after tag <body> (it may have attributes) line <h1>Hello</h1>.

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 value str:

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