#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^ ([\w-_ ]+):\n\n +Type: Ethernet\n +Hardware.+\n +BSD Device Name: (.+)\n +IPv4 Addresses: (192[\.\d]+)$"
Local $sString = "ETHERNET CONNECTED, NO WI-FI" & @CRLF & _
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF & _
"Below Source Text from Mac Shell Script:" & @CRLF & _
"system_profiler SPNetworkDataType" & @CRLF & _
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF & _
"Network:" & @CRLF & _
"" & @CRLF & _
" Thunderbolt Ethernet Slot 1:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en8" & @CRLF & _
" IPv4 Addresses: 192.168.1.15" & @CRLF & _
" IPv4:" & @CRLF & _
" AdditionalRoutes:" & @CRLF & _
" DestinationAddress: 192.168.1.15" & @CRLF & _
" SubnetMask: 255.255.255.255" & @CRLF & _
" DestinationAddress: 169.254.0.0" & @CRLF & _
" SubnetMask: 255.255.0.0" & @CRLF & _
" Addresses: 192.168.1.15" & @CRLF & _
" ARPResolvedHardwareAddress: 2c:b0:5d:25:af:69" & @CRLF & _
" ARPResolvedIPAddress: 192.168.1.1" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" ConfirmedInterfaceName: en8" & @CRLF & _
" Interface Name: en8" & @CRLF & _
" Network Signature: IPv4.Router=192.168.1.1;IPv4.RouterHardwareAddress=2c:b0:5d:25:af:69" & @CRLF & _
" Router: 192.168.1.1" & @CRLF & _
" Subnet Masks: 255.255.255.0" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" DNS:" & @CRLF & _
" Server Addresses: 192.168.1.1" & @CRLF & _
" DHCP Server Responses:" & @CRLF & _
" Domain Name Servers: 192.168.1.1" & @CRLF & _
" Lease Duration (seconds): 0" & @CRLF & _
" DHCP Message Type: 0x05" & @CRLF & _
" Routers: 192.168.1.1" & @CRLF & _
" Server Identifier: 192.168.1.1" & @CRLF & _
" Subnet Mask: 255.255.255.0" & @CRLF & _
" Ethernet:" & @CRLF & _
" MAC Address: 00:50:b6:ca:f0:dc" & @CRLF & _
" Media Options: Full Duplex, Flow Control" & @CRLF & _
" Media Subtype: 1000baseT" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Sleep Proxies:" & @CRLF & _
" 1 Family Room Apple TV:" & @CRLF & _
" Marginal Power: 60" & @CRLF & _
" Metric: 703560" & @CRLF & _
" Portability: 35" & @CRLF & _
" Total Power: 63" & @CRLF & _
" Type: 70" & @CRLF & _
" Service Order: 0" & @CRLF & _
"" & @CRLF & _
" Wi-Fi:" & @CRLF & _
"" & @CRLF & _
" Type: AirPort" & @CRLF & _
" Hardware: AirPort" & @CRLF & _
" BSD Device Name: en0" & @CRLF & _
" IPv4 Addresses: 192.168.1.16" & @CRLF & _
" IPv4:" & @CRLF & _
" AdditionalRoutes:" & @CRLF & _
" DestinationAddress: 192.168.1.16" & @CRLF & _
" SubnetMask: 255.255.255.255" & @CRLF & _
" DestinationAddress: 169.254.0.0" & @CRLF & _
" SubnetMask: 255.255.0.0" & @CRLF & _
" Addresses: 192.168.1.16" & @CRLF & _
" ARPResolvedHardwareAddress: 2c:b0:5d:25:af:69" & @CRLF & _
" ARPResolvedIPAddress: 192.168.1.1" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" ConfirmedInterfaceName: en0" & @CRLF & _
" Interface Name: en0" & @CRLF & _
" Network Signature: IPv4.Router=192.168.1.1;IPv4.RouterHardwareAddress=2c:b0:5d:25:af:69" & @CRLF & _
" Router: 192.168.1.1" & @CRLF & _
" Subnet Masks: 255.255.255.0" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" DNS:" & @CRLF & _
" Server Addresses: 192.168.1.1" & @CRLF & _
" DHCP Server Responses:" & @CRLF & _
" Domain Name Servers: 192.168.1.1" & @CRLF & _
" Lease Duration (seconds): 0" & @CRLF & _
" DHCP Message Type: 0x05" & @CRLF & _
" Routers: 192.168.1.1" & @CRLF & _
" Server Identifier: 192.168.1.1" & @CRLF & _
" Subnet Mask: 255.255.255.0" & @CRLF & _
" Ethernet:" & @CRLF & _
" MAC Address: 28:cf:e9:17:e0:d1" & @CRLF & _
" Media Options: " & @CRLF & _
" Media Subtype: Auto Select" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 2" & @CRLF & _
"" & @CRLF & _
" Thunderbolt Ethernet:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en6" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 1" & @CRLF & _
"" & @CRLF & _
" Wi-Fi:" & @CRLF & _
"" & @CRLF & _
" Type: AirPort" & @CRLF & _
" Hardware: AirPort" & @CRLF & _
" BSD Device Name: en0" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Ethernet:" & @CRLF & _
" MAC Address: 28:cf:e9:17:e0:d1" & @CRLF & _
" Media Options: " & @CRLF & _
" Media Subtype: Auto Select" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 2" & @CRLF & _
"" & @CRLF & _
" USB Ethernet:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en3" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 3" & @CRLF & _
"" & @CRLF & _
" AX88179 USB 3.0 to Gigabit Ethernet:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en7" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 4" & @CRLF & _
"" & @CRLF & _
" Thunderbolt FireWire:" & @CRLF & _
"" & @CRLF & _
" Type: FireWire" & @CRLF & _
" Hardware: FireWire" & @CRLF & _
" BSD Device Name: fw0" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Ethernet:" & @CRLF & _
" MAC Address: 00:50:b6:10:00:00:5d:31" & @CRLF & _
" Media Options: Full Duplex" & @CRLF & _
" Media Subtype: Auto Select" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 5" & @CRLF & _
"" & @CRLF & _
" iPhone:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en5" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 6" & @CRLF & _
"" & @CRLF & _
" Bluetooth PAN:" & @CRLF & _
"" & @CRLF & _
" Type: Ethernet" & @CRLF & _
" Hardware: Ethernet" & @CRLF & _
" BSD Device Name: en4" & @CRLF & _
" IPv4:" & @CRLF & _
" Configuration Method: DHCP" & @CRLF & _
" IPv6:" & @CRLF & _
" Configuration Method: Automatic" & @CRLF & _
" Proxies:" & @CRLF & _
" Exceptions List: *.local, 169.254/16" & @CRLF & _
" FTP Passive Mode: Yes" & @CRLF & _
" Service Order: 7" & @CRLF & _
"" & @CRLF & _
"~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF & _
"Type: Ethernet\n +Hardware.+\n +BSD.+\n +IPv4 Addresses: 192[\.\d]+$"
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