#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)GigabitEthernet1\/1\/1(?:(?!interface GigabitEthernet)[\s\S])*(vlan.*40(?:9[12]|[6-8][0-9]|5[2-9]))"
Local $sString = "interface GigabitEthernet1/1/1" & @CRLF & _
" description link-to-someswitch-Gi2/0/1" & @CRLF & _
" switchport access vlan 3109" & @CRLF & _
" switchport trunk allowed vlan 300,301,350,358,800,3109" & @CRLF & _
" switchport trunk encapsulation dot1q" & @CRLF & _
" switchport trunk native vlan 3109" & @CRLF & _
" switchport mode dynamic desirable" & @CRLF & _
" srr-queue bandwidth share 40 20 20 20" & @CRLF & _
" srr-queue bandwidth shape 10 0 0 0" & @CRLF & _
" priority-queue out " & @CRLF & _
" no snmp trap link-status" & @CRLF & _
" mls qos trust dscp" & @CRLF & _
" spanning-tree portfast disable" & @CRLF & _
"!" & @CRLF & _
"interface GigabitEthernet1/1/2" & @CRLF & _
" description link-to-someswitch2-Gi2/0/1" & @CRLF & _
" switchport access vlan 3609" & @CRLF & _
" switchport trunk allowed vlan 300,301,350,358,800,3609,4088" & @CRLF & _
" switchport trunk encapsulation dot1q" & @CRLF & _
" switchport trunk native vlan 3109" & @CRLF & _
" switchport mode dynamic desirable" & @CRLF & _
" srr-queue bandwidth share 40 20 20 20" & @CRLF & _
" srr-queue bandwidth shape 10 0 0 0" & @CRLF & _
" priority-queue out " & @CRLF & _
" no snmp trap link-status" & @CRLF & _
" mls qos trust dscp" & @CRLF & _
" spanning-tree portfast disable" & @CRLF & _
"" & @CRLF & _
"interface GigabitEthernet1/1/1" & @CRLF & _
" description link-to-someswitch-Gi2/0/1" & @CRLF & _
" switchport access vlan 3109" & @CRLF & _
" switchport trunk allowed vlan 300,301,350,358,800,4088" & @CRLF & _
" switchport trunk encapsulation dot1q" & @CRLF & _
" switchport trunk native vlan 3109" & @CRLF & _
" switchport mode dynamic desirable" & @CRLF & _
" srr-queue bandwidth share 40 20 20 20" & @CRLF & _
" srr-queue bandwidth shape 10 0 0 0" & @CRLF & _
" priority-queue out " & @CRLF & _
" no snmp trap link-status" & @CRLF & _
" mls qos trust dscp" & @CRLF & _
" spanning-tree portfast disable" & @CRLF & _
""
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