lets say I\'ve written a function to evaluate a simple mathematical operation, and I have some user input in a string such as:
\"1 + [2 + [3+4]]\"
How can I parse these squa
Use a stack. When you encounter an open bracket, push whatever you're working on onto the stack and start the new expression. When you hit a closing bracket, pop the stack and use the expression you just calculated as the next item. Or, as previous posters have said, use recursion or a tree.