#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)^step\s*(\d+)\s*(.*?)\s*(?=^step\s*\d|\Z)"
Local $sString = "This is the first line of the file." & @CRLF & _
"here we tell you to make a tea." & @CRLF & _
"" & @CRLF & _
"step 1" & @CRLF & _
"" & @CRLF & _
"Pour more than enough water for a cup of tea into a regular pot, and bring it to a boil." & @CRLF & _
"" & @CRLF & _
"step " & @CRLF & _
"2" & @CRLF & _
"" & @CRLF & _
" This will prevent the steeping water from dropping in temperature as soon as it is poured in." & @CRLF & _
"" & @CRLF & _
"step 3 " & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"When using tea bags, the measuring has already been done for you - generally it's one tea bag per cup."
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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