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 square brackets and extract first the inner-most text (3+4), evaluate it, then parse the outer braces (2 + 7)?
I have a rudimentary understanding of Regex search and replace, but I know they won't do recursion like this.
I'd like some basic java code to do this, not yet another jar/API if I can avoid it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…