I'm very new to RegEx expressions and the problem is that I want to split a string with some conditions using RegEx. Let's say I want to split by comma, but if it's not followed by some certain things. The following example shows everything:
str = "a , b=10 , c=add(3,b) , d"
certainThings = ["add" , "sub"]
output of str.split(',') which splits only by comma is: ["a" , "b=10" , "c=add(3" , "b)" , "d"].
But I don't want to split on the 3rd comma as it's followed by one of the elements of the certainThings array.
The expected output is: ["a" , "b=10" , "c=add(3,b)" , "d"].
A possible solution might be to split by comma and concatenate two elements if the prior contains one elements of the certainThings array. But I think there should be a better way of doing this by RegEx expressions.