#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?s)(?:Nameservers[^\n]*\n.*?)*(?>Hostname:\s+([\S]+)\n)"
Local $sString = "" & @CRLF & _
"" & @CRLF & _
"Domain: myDomain.int" & @CRLF & _
"DNS: myDomain.int" & @CRLF & _
"Registered: 2013-05-17" & @CRLF & _
"Expires: 2023-05-31" & @CRLF & _
"Registration period: 1 year" & @CRLF & _
"VID: no" & @CRLF & _
"DNSSEC: Unsigned delegation, DNSSEC disabled, no records" & @CRLF & _
"Status: Active" & @CRLF & _
"" & @CRLF & _
"Registrant" & @CRLF & _
"Handle: ***N/A***" & @CRLF & _
"Name: myName Corp" & @CRLF & _
"Attention: Reggie Person" & @CRLF & _
"Address: SomeStreet 17" & @CRLF & _
"Postalcode: numericZip" & @CRLF & _
"City: myCity" & @CRLF & _
"Country: XX" & @CRLF & _
"Phone: +12 34 56 78 90" & @CRLF & _
"" & @CRLF & _
"Nameservers" & @CRLF & _
"Hostname: ns1.dom.ext" & @CRLF & _
"Hostname: ns2.dom.ext" & @CRLF & _
"Hostname: ns3.dom.ext" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "### push(@nameservers, $1); <-- it works :)\n"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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