#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?:\)[;,]( )|([A-Z\d]+))|."
Local $sString = "4A(4,5,6,7,8,9); 4B(4,5,7,8); 3A(1,2,3); 3B(1,2,3), 3C(1,2)" & @CRLF & _
"4A (4,5,6,7,8,9); 4B(4,5,7,8); 3A(1,2,3); 3B(1,2,3), 3C(1,2)" & @CRLF & _
"4A (4,5, skip 8,9); 4B(4,5,7,8); 3A(1,2,3); 3B(1,2,3), 3C(1,2)" & @CRLF & _
"4 A(4,5,6); 4B(4,5,7,8); 3A(1,2,3); 3B(1,2,3), 3C(1,2)"
Local $sSubst = "$2$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