I am struggling to create a regular expression that can transform a string formatted like
(person,item(bought,paid),shipping(address(city,state)))
into a different format like this:
person
item
* bought
* paid
shipping
* address
** city
** state
My current knowledge of regular expressions is not sufficient for this task. I attempted the following approach, but it is not going to work:
var stg = "(person,item(bought,paid),shipping(address(city,state)))"
var separators = [' ', '\"\\\(', '\\\)\"', ','];
stg = stg.split(new RegExp(separators.join('|'), 'g'));
Note: the structure of the string can change. My aim is to start a child element with * when a ( is encountered and close it when ). This might require a loop with conditional statements.