#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?:^\K.*+\R?){6}"
Local $sString = "Question text" & @CRLF & _
"A. Answer Option" & @CRLF & _
"B. Answer Option" & @CRLF & _
"C. Answer Option" & @CRLF & _
"D. Answer Option" & @CRLF & _
"Explanation text" & @CRLF & _
"Question text" & @CRLF & _
"E. Answer Option" & @CRLF & _
"F. Answer Option" & @CRLF & _
"G. Answer Option" & @CRLF & _
"H. Answer Option" & @CRLF & _
"Explanation text" & @CRLF & _
"Question text" & @CRLF & _
"I. Answer Option" & @CRLF & _
"J. Answer Option" & @CRLF & _
"K. Answer Option" & @CRLF & _
"L. Answer Option" & @CRLF & _
"Explanation text" & @CRLF & _
"Question text" & @CRLF & _
"M. Answer Option"
Local $sSubst = "Explanation\n$0"
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