Hey, thanks for asking your first SO question! Welcome. Question. What larger problem are you trying to solve here? Are you interfacing with a system that you can't change? Sometimes when trying to parse complicated strings or syntax the answer can be to solve a different problem. For example, if your data was a valid JSON string, then you could just parse it, manipulate it as an array, and then convert it back to JSON.
Your question is not clear. What do you want to return for 'a,b],c'? Is the comma between a and b inside or outside of the brackets? Or, if it is the case that such string is outside of your consideration, then state what kind of strings are subject to your issue.
'a,b],c'? Is the comma betweenaandbinside or outside of the brackets? Or, if it is the case that such string is outside of your consideration, then state what kind of strings are subject to your issue.