#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?P<hostname>[\w-_]+)\s+(?P<localInterface>[A-Za-z]+\d+(?:\/\d+)*)\s+(?P<holdTime>\d+)\s+(?P<capabilities>[A-Z]+)\s+(?P<remoteInterface>[A-Za-z]+\d+(?:\/\d+)*) "
Local $sString = "sh cdp nei" & @CRLF & _
"" & @CRLF & _
"Capability Codes: R - Router, T - Trans-Bridge, B - Source-Route-Bridge" & @CRLF & _
" S - Switch, H - Host, I - IGMP, r - Repeater," & @CRLF & _
" V - VoIP-Phone, D - Remotely-Managed-Device," & @CRLF & _
" s - Supports-STP-Dispute" & @CRLF & _
"" & @CRLF & _
"Device-ID Local Intrfce Hldtme Capability Platform Port ID" & @CRLF & _
"CHOD-MGMT-STACK.mhmp" & @CRLF & _
" mgmt0 129 S I WS-C2960X-48T Gig1/0/25 " & @CRLF & _
"SPINE-401(FDO22041YMP)" & @CRLF & _
" Eth1/49 153 R S s N9K-C9336PQ Eth1/36 " & @CRLF & _
"SPINE-402(FDO22081W5Y)" & @CRLF & _
" Eth1/50 176 R S s N9K-C9336PQ Eth1/36 " & @CRLF & _
"IPN-2-CH(FDO221610MG)" & @CRLF & _
" Eth1/51 125 R S s N9K-C93180YC- Eth1/51 " & @CRLF & _
"IPN-2-CH(FDO221610MG)" & @CRLF & _
" Eth1/52 125 R S s N9K-C93180YC- Eth1/52 " & @CRLF & _
"IPN-1-KCP(FDO22152M53)" & @CRLF & _
" Eth1/54 143 R S s N9K-C93180YC- Eth1/54 " & @CRLF & _
"" & @CRLF & _
"Total entries displayed: 6" & @CRLF & _
"" & @CRLF & _
"IPN-1-CH# sh lldp nei" & @CRLF & _
"" & @CRLF & _
"Capability codes:" & @CRLF & _
" (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device" & @CRLF & _
" (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other" & @CRLF & _
"Device ID Local Intf Hold-time Capability Port ID " & @CRLF & _
"SPINE-401 Eth1/49 120 BR Eth1/36 " & @CRLF & _
"SPINE-402 Eth1/50 120 BR Eth1/36 " & @CRLF & _
"IPN-2-CH Eth1/51 120 BR Ethernet1/51 " & @CRLF & _
"IPN-2-CH Eth1/52 120 BR Ethernet1/52 " & @CRLF & _
"IPN-1-KCP Eth1/54 120 BR Ethernet1/54 " & @CRLF & _
"Total entries displayed: 5"
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