I'm trying to parse apart a string like this with javascript:
var mystr = "param1('stringValue'), param2(IntegerValue IntegerValue)";
Where in the end I need to get each of the param names (param1 and param2) and values (either one string value, or two integer values).
However, the original string could have any number of parameters, such as:
"param1('stringValue')"
"param1('stringValue'), param2(IntegerValue IntegerValue), param2(IntegerValue IntegerValue)"
Requirements:
- Between each parameter is a comma, and values are within the parentheses.
- Within the parentheses could either be one string value, or two integers with a space in between.
- There could be any number of parameters (but at least 1)
,then for each value replace)with""and split after(then you can have an array where on every position you have the name of the param ( param1, param2) and the actual parameter. Or you could format your string to be a JSON.,.