#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\s*"
Local $sString = "1 Question" & @CRLF & _
"2 Answer 1" & @CRLF & _
"3 Answer 2" & @CRLF & _
"4 Answer 3" & @CRLF & _
"5 Answer 4" & @CRLF & _
"6 Answer 5" & @CRLF & _
"7 Question" & @CRLF & _
"8 Answer 1" & @CRLF & _
"9 Answer 2" & @CRLF & _
"10 Answer 3" & @CRLF & _
"11 Answer 4" & @CRLF & _
"12 Answer 5"
Local $sSubst = "<h1>$1</h1><p>$2</p><br><p>$3</p><br><p>$4</p><br><p>$5</p>"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm