# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/,|\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\)/|$&|/gm;t' <<< "SELECT TempSynop.Field1 AS Nosta ,CInt(Left([Field2], 4)) AS Tahun ,CInt(Right([Field2], 2)) AS Bulan ,CInt(Left([Field3], 2)) AS Tanggal ,CInt(Mid([Field3], 3, 2)) AS Jam ,Left([Field5], 1) AS NAwan ,CInt(Mid([Field5], 2, 2) \"0\") AS WDir ,CInt(\"0\" Right([Field5], 2)) AS WSpeed ,Right([Field4], 2) AS Visibility ,Mid([Field12], 2, 2) AS PresentW ,Right([Field12], 2) AS PastW2 ,CInt(Right([Field9], 4)) / 10 AS PSea1 ,IIf([PSea1] < 500, [PSea1] 1000, [PSea1]) AS PSea ,CInt(Right([Field8], 4)) / 10 AS PSta1 ,IIf([PSta1] < 500, [PSta1] 1000, [PSta1]) AS PSta ,CInt(Right([Field6], 3)) / 10 AS TEMP ,CInt(Right([Field7], 3)) / 10 AS DewPoint ,Right([Field11], 4) AS RR2 ,Mid([Field13], 2, 1) AS Nh ,Mid([Field13], 3, 1) AS Cl ,Mid([Field13], 4, 1) AS Cm ,Mid([Field13], 5, 1) AS Ch FROM (SELECT AA, BB, CC FROM TempSynop) ORDER BY TempSynop.Field1;
Find all commas that are not in parenthesis. Used in SQL_Pretty_Format()
,|\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) for vbScript |$&|
,|\((?:[^()]++|(?R))*\) Recursive for AutoHotkey |$0|"
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 SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html