#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)O\s+(?P<O>\d+\.\d+\.\d+\.\d+.*(?:[\r\n]+[^\S\r\n]+.*)?)"
Local $sString = "Gateway of last resort is not set" & @CRLF & _
"" & @CRLF & _
" 10.0.1.0/8 is variably subnetted, 4 subnets, 2 masks" & @CRLF & _
"C 10.1.0.0/24 is directly connected, Ethernet1/0" & @CRLF & _
"L 10.1.0.1/32 is directly connected, Ethernet0/0" & @CRLF & _
"C 10.2.0.0/24 is directly connected, Ethernet0/1" & @CRLF & _
"L 19.18.2.1/32 is directly connected, Serial2/1" & @CRLF & _
"O 19.18.3.0/20 [110/128] via 19.18.2.2, 00:00:50, Serial1/1" & @CRLF & _
" [110/128] via 19.18.1.2, 00:00:50, Serial1/0" & @CRLF & _
"" & @CRLF & _
"O 12.18.3.1/20 [110/128] via 19.18.2.2, 00:00:50, Serial1/1" & @CRLF & _
" [110/128] via 19.18.1.2, 00:00:50, Serial1/0" & @CRLF & _
"" & @CRLF & _
"O 12.18.1.0/20 [110/128] via 19.18.2.2, 00:00:50, Serial0/1" & @CRLF & _
" [110/128] via 19.18.1.2, 00:00:50, Serial0/0"
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