#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?s).*?(\z|\d+\.\d+\.\d+\.\d+)"
Local $sString = "Nmap scan report for 192.168.0.21" & @CRLF & _
"Host is up (0.18s latency)." & @CRLF & _
"Not shown: 1 filtered port" & @CRLF & _
"Some closed ports may be reported as filtered due to --defeat-rst-ratelimit" & @CRLF & _
"PORT STATE SERVICE" & @CRLF & _
"22/tcp open ssh" & @CRLF & _
"" & @CRLF & _
"Nmap scan report for 192.168.0.29" & @CRLF & _
"Host is up (0.029s latency)." & @CRLF & _
"Not shown: 1 filtered port" & @CRLF & _
"Some closed ports may be reported as filtered due to --defeat-rst-ratelimit" & @CRLF & _
"PORT STATE SERVICE" & @CRLF & _
"22/tcp open ssh" & @CRLF & _
"" & @CRLF & _
"Nmap scan report for 192.168.0.25" & @CRLF & _
"Host is up (0.15s latency)." & @CRLF & _
"Not shown: 1 filtered port" & @CRLF & _
"Some closed ports may be reported as filtered due to --defeat-rst-ratelimit" & @CRLF & _
"PORT STATE SERVICE" & @CRLF & _
"22/tcp open ssh"
Local $sSubst = "$1\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