#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?:(?:^edit\ \"(.+)\"$\n)(?:^set\ uuid\ ([a-f0-9]{8}\-(?:[a-f0-9]{4}\-){3}[a-f0-9]{12})$\n)(?:(?:^set\ comment\ )((?:(?!^set\ )(?:.*$\n))+)(?=^set\ ))?(?:^set\ service\ (\".+\")$\n)?(?:^set\ extip\ ((?:(?:\d{1,3}\.){3}(?:\d{1,3}))(?:\-(?:\d{1,3}\.){3}(?:\d{1,3}))?)$\n)(?:^set\ extintf\ \"(.+)\"$\n)(?:^(set\ portforward)\ (enable)$\n)?(?:^(set\ color)\ (\d{1,2})$\n)?(?:^set\ mappedip\ \"((?:(?:\d{1,3}\.){3}(?:\d{1,3}))(?:\-(?:\d{1,3}\.){3}(?:\d{1,3}))?)\"$\n)(?:^(set\ protocol)\ (.+)$\n)?(?:^(set\ extport)\ (\d{1,5}(?:\-\d{1,5})?)$\n)?(?:^(set\ mappedport)\ (\d{1,5}(?:\-\d{1,5})?)$\n)?(?:^next$\n(?:^$\n)?))"
Local $sString = "edit "VIP [DNS сервер site.com]"" & @CRLF & _
"set uuid abcdef01-2345-6789-abcd-ef0123456789" & @CRLF & _
"set comment "Публикация IP-адреса для проекта " & @CRLF & _
"\"TEST\" в ДЦ \"Облако\""" & @CRLF & _
"set service "HTTP Webserver"" & @CRLF & _
"set extip 100.200.254.20" & @CRLF & _
"set extintf "DMZ [VLAN 100]"" & @CRLF & _
"set portforward enable" & @CRLF & _
"set color 3" & @CRLF & _
"set mappedip "10.100.200.5"" & @CRLF & _
"set protocol udp" & @CRLF & _
"set extport 53" & @CRLF & _
"set mappedport 2000-65535" & @CRLF & _
"next" & @CRLF & _
"" & @CRLF & _
"edit "VIP [NTP сервер site.com]"" & @CRLF & _
"set uuid abcdef01-2345-6789-abcd-ef0123456789" & @CRLF & _
"set comment "Публикация IP-адреса для проекта " & @CRLF & _
"\"TEST\" в ДЦ \"Облако\""" & @CRLF & _
"set service "NTP TCP Server" "NTP UDP Server"" & @CRLF & _
"set extip 100.200.254.20-100.200.254.21" & @CRLF & _
"set extintf "DMZ [VLAN 100]"" & @CRLF & _
"set portforward enable" & @CRLF & _
"set color 3" & @CRLF & _
"set mappedip "10.100.200.5-10.100.200.6"" & @CRLF & _
"set protocol udp" & @CRLF & _
"set extport 123" & @CRLF & _
"set mappedport 1000-1999" & @CRLF & _
"next" & @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