#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(\d{1,3}(?:\.\d{1,3}){2}\.(\d{1,3}))(?:(?:-|\s+to\s+)(\d{1,3}(?![\d\.]))|(?:-|\s*to\s+)(\d{1,3}(?:\.\d{1,3}){3})|\s+(25\d(?:\.\d{1,3}){3})|\s*\/(\d{1,3}))?"
Local $sString = "ip: "47.1.2.3"" & @CRLF & _
"range: "47.1.2.3-4"" & @CRLF & _
"ip range: "47.1.2.3-47.1.2.4"" & @CRLF & _
"ip to range: "47.1.2.3 to 4"" & @CRLF & _
"ip to ip range: "47.1.2.3 to 47.1.2.4"" & @CRLF & _
"ip CIDR: "47.1.2.4/32"" & @CRLF & _
"ip Mask: "47.1.2.4 255.255.255.255"" & @CRLF & _
"" & @CRLF & _
"what you want:"47.1.2.3 to 4, 47.1.2.7, 47.1.3.9-47.1.3.19""
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