Write three regular expressions that will be passed to re.sub() in order to modify the body element in our HTML file:
body_insert that will be used to add elements immediately after the body element opening tag: <body>.body_append that will be used to add elements immediately before the body element closing tag: </body>.body_rewrite that will be used to replace the content of the body element: <body>content</body>.Details to take into account:
<body> will be followed by line break \n, you should match after the line break.</body> will be preceded by line break \n, you should match before the line break.body_rewrite should match the content of the body element, but not the body tags.index = '''
<body>
<p>This is a paragraph and <a href="https://edabit.com">this is a link</a>.</p>
</body>
'''
body_insert = "yourregularexpressionhere"
body_append = "yourregularexpressionhere"
body_rewrite = "yourregularexpressionhere"re.sub(body_insert, ' <p>Pre-Paragraph</p>\n', index) ➞
'''
<body>
<p>Pre-Paragraph</p>
<p>This is a paragraph and <a href="https://edabit.com">this is a link</a>.</p>
</body>
'''re.sub(body_append, '\n <p>Post-Paragraph</p>', index) ➞
'''
<body>
<p>This is a paragraph and <a href="https://edabit.com">this is a link</a>.</p>
<p>Post-Paragraph</p>
</body>
'''re.sub(body_rewrite, ' <p>Anti-Paragraph</p>', index) ➞
'''
<body>
<p>Anti-Paragraph</p>'
</body>
'''import re from the code.