#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?m)^(\d{10}):\s+(.+)"
Local $sString = "1652855102: New connection from xx.xx.xx.xx on port xxxx." & @CRLF & _
"1652855102: Socket error on client <unknown>, disconnecting." & @CRLF & _
"1652855102: Received PUBLISH from 16838547124974742985 (d0, q1, r0, m235, 's/uc/mpd/16838547124974742985', ... (30 bytes))" & @CRLF & _
"1652855102: Sending PUBACK to 16838547124974742985 (m235, rc0)" & @CRLF & _
"1652855102: Sending PUBLISH to mqtt_7811e829.e2e5e8 (d0, q1, r0, m42277, 's/uc/mpd/16838547124974742985', ... (30 bytes))" & @CRLF & _
"1652855102: Sending PUBLISH to dad3d73-013c-4274-a782-cdd6f2ebbc77 (d0, q0, r0, m0, 's/uc/mpd/16838547124974742985', ... (30 bytes))" & @CRLF & _
"1652855102: Received PUBACK from mqtt_7811e829.e2e5e8 (Mid: 42277, RC:0)" & @CRLF & _
"1652855103: Received DISCONNECT from 16838547082470259932" & @CRLF & _
"1652855103: Client 16838547082470259932 disconnected."
Local $sSubst = "$1|$2"
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