I have a long string that contains data formatted in the following way:
var str = "parent /n /t child /n /t child /n /t /t grandchild /n parent";
If you print this out you get a tree structure like directories. I am trying to figure out a way/algorithm to individually extract every parent and child and children of the aforementioned and store them in an array for each of them so that I can access them later for other useful purposes. I was thinking of using a regular expression to extract the substrings since there is some sort of pattern but I am not an expert in that field and do not know if it is worth the time. Any other ways to approach this problem or is this the best way?
A child is always preceded with \n\t
A child's child "" "" "" \n\t\t (possibly spaces between the literals)
If the string is searched the substrings that have been searched should be stored somehow for compiling the node later.