#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(\S)(,)(\S)"
Local $sString = "SELECT tbl_Generic_Tool.Generic_Type_ID, tbl_ref_Generic_Type.Generic_Type," & @CRLF & _
"" & @CRLF & _
"tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No ,Min(tbl_ref_Phase.Phase) AS FirstOfPhase,tbl_ref_Building.Building_Abbrev,tbl_ref_Status_Equipment.Status_Equipment" & @CRLF & _
"GROUP BY" & @CRLF & _
" tbl_Generic_Tool.Generic_Type_ID,tbl_ref_Generic_Type.Generic_Type,tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No,tbl_ref_Building.Building_Abbrev,tbl_Hex.Status_Equipment_ID,tbl_ref_Status_Equipment.Status_Equipment" & @CRLF & _
"HAVING" & @CRLF & _
" (((tbl_Hex.ODD_Micap) < CONVERT(DATE,GETDATE()))" & @CRLF & _
" AND ((tbl_Hex.Status_Equipment_ID) = 2)))¦ AS H" & @CRLF & _
" LEFT JOIN tbl_POC_Assigned ON H.Hex_ID = tbl_POC_Assigned.Hex_ID" & @CRLF & _
"GROUP BY" & @CRLF & _
" H.Generic_Type" & @CRLF & _
" ,H.Building_Abbrev" & @CRLF & _
" ,H.ODD_Micap" & @CRLF & _
" ,H.Hex_ID" & @CRLF & _
" ,H.Hex_No" & @CRLF & _
" ,H.Status_Equipment"
Local $sSubst = "\1\2 \3"
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