# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\s*/<h1>$1<\/h1><p>$2<\/p><br><p>$3<\/p><br><p>$4<\/p><br><p>$5<\/p>/g;t' <<< "1 Question
2 Answer 1
3 Answer 2
4 Answer 3
5 Answer 4
6 Answer 5
7 Question
8 Answer 1
9 Answer 2
10 Answer 3
11 Answer 4
12 Answer 5"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html