en.javascript.info/9-regular-expressions/14-regexp-lookahead-lookbehind/2-insert-after-head/task.md
2020-01-19 20:32:27 +01:00

30 lines
500 B
Markdown

# 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:
```js
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
<html>
<body style="height: 200px"><h1>Hello</h1>
...
</body>
</html>
```