#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "\b(?:(port)|(dpi)|(fb_height)|(fb_width))="\K\d+"
Local $sString = "bst.instance.red.port="5555"" & @CRLF & _
"bst.instance.red.dpi="240"" & @CRLF & _
"bst.instance.red.fb_height="900"" & @CRLF & _
"bst.instance.red.fb_width="1600"" & @CRLF & _
"bst.instance.red.first_boot="0"" & @CRLF & _
"bst.instance.redb.port="2000"" & @CRLF & _
"bst.instance.redb.dpi="120"" & @CRLF & _
"bst.instance.redb.fb_height="300"" & @CRLF & _
"bst.instance.redb.fb_width="800"" & @CRLF & _
"bst.instance.redb.first_boot="0"" & @CRLF & _
"bst.instance.redc.port="2000"" & @CRLF & _
"bst.instance.redc.dpi="120"" & @CRLF & _
"bst.instance.redc.fb_height="300"" & @CRLF & _
"bst.instance.redc.fb_width="800"" & @CRLF & _
"bst.instance.redc.first_boot="0""
Local $sSubst = "${1:+111}${2:+222}${3:+333}${4:+444}"
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