#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)This is what I want to print$"
Local $sString = "This a line of something I dont need" & @CRLF & _
"More of what I dont need" & @CRLF & _
"This is what I want to print " & @CRLF & _
"This is the pattern I need to find" & @CRLF & _
"This is unimportant" & @CRLF & _
"So is this" & @CRLF & _
"This too" & @CRLF & _
"As well as this" & @CRLF & _
"This is what I want to print"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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