#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mx)A\s+change\s+to\s+" & @CRLF & _
"(?:(?:sub)?headings?|tariff\s+item)" & @CRLF & _
"\s+\d[0-9.]*" & @CRLF & _
"(?:\s+through\s+\d[0-9.]*)?" & @CRLF & _
"\s+from(?:(?:,?\s+(?:sub)?headings?\s+\d[0-9.]*)+(?:\s+or\s+\d[0-9.]*)*\s+or)?" & @CRLF & _
"\s+any\s+other\s+(?:heading|chapter)\."
Local $sString = "A change to headings 0101 through 0106 from any other chapter." & @CRLF & _
"A change to subheadings 0712.20 through 0712.39 from any other chapter." & @CRLF & _
"A change to heading 0903 from any other chapter." & @CRLF & _
"A change to subheading 1806.20 from any other heading." & @CRLF & _
"A change to subheading 1207.99 from any other chapter." & @CRLF & _
"A change to heading 4302 from any other heading." & @CRLF & _
"A change to subheading 4105.10 from heading 4102 or any other chapter." & @CRLF & _
"A change to subheading 4105.30 from heading 4102, subheading 4105.10 or any other chapter." & @CRLF & _
"A change to subheading 4106.21 from subheading 4103.10 or any other chapter." & @CRLF & _
"A change to subheading 4106.22 from subheadings 4103.10 or 4106.21 or any other chapter." & @CRLF & _
"A change to tariff item 7304.41.30 from subheading 7304.49 or any other chapter."
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