Okay, i have this case where comma are inside parenthesis, I want to match the commas that are only outside the parenthesis.
Input : color-stop(50%,rgb(0,0,0
Here is the regex which works perfectly for your input.
,(?![^()]*(?:\([^()]*\))?\))
DEMO
Explanation:
, ','
(?! look ahead to see if there is not:
[^()]* any character except: '(', ')' (0 or
more times)
(?: group, but do not capture (optional):
\( '('
[^()]* any character except: '(', ')' (0 or
more times)
\) ')'
)? end of grouping, ? after the non-capturing group makes the
whole non-capturing group as optional.
\) ')'
) end of look-ahead