Push the left parenthesis onto the top of stack.
push the string between two left parenthesis onto the top of the stack given that second left parenthesis does exist then goto step 3 else push the string that is in between a left and right parenthesis onto the top of the stack and goto step4.
push the left parenthesis after the string(string between two left parenthesis) onto the top of the stack. Repeat steps 1 to 3 until you encounter a right parenthesis.
Once you encountered a right parenthesis, remove the top two elements that is the string(string between two left parenthesis) or if applicable the string(string between the left and immediate right parenthesis) and the left parenthesis
from the stack and adjust the top index and string index. Now you have
the content 1.
Repeat the step 4 until you have got all the contents.