#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ix)\b(" & @CRLF & _
" # MAC address like xx:xx:xx:xx:xx:xx" & @CRLF & _
" [0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}" & @CRLF & _
" |" & @CRLF & _
" # MAC address like xx-xx-xx-xx-xx-xx" & @CRLF & _
" [0-9a-f]{2}-[0-9a-f]{2}-[0-9a-f]{2}-[0-9a-f]{2}-[0-9a-f]{2}-[0-9a-f]{2}" & @CRLF & _
" |" & @CRLF & _
" # MAC address like xxxx.xxxx.xxxx" & @CRLF & _
" [0-9a-f]{4}\.[0-9a-f]{4}\.[0-9a-f]{4}" & @CRLF & _
" |" & @CRLF & _
" # IPv4 address in dotted-quad format" & @CRLF & _
" # Not a lot of value for our needs in checking range of each octet" & @CRLF & _
" # Need to be more mindful of performance here anyway." & @CRLF & _
" \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" & @CRLF & _
")\b"
Local $sString = "192.168.1.2" & @CRLF & _
"10.0.0.0" & @CRLF & _
"ff:ff:ff:ff:ff:ff" & @CRLF & _
"FF-FF-FF-FF-FF-FF" & @CRLF & _
"FFFF.FFFF.FFFF" & @CRLF & _
"ffff.ffff.ffff" & @CRLF & _
"blah127.0.0.1haha" & @CRLF & _
"foo127.0.0.1" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "\1"
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