In java, I am trying to write a regular expression that will correspond to a unit in a mathematical expression, i.e. things that are between the operators
I mean, in an expression like 1 + [1 + 2], the regular expression should match the first 1, and then [1 + 2].
I have * [([- +]? \ D + (\. \ D +)?) (\ [. + \])] *
Of which ([- +]? \ D + (\. \ D +)?) Is supposed to correspond to any number and
(\ [+. \])
It is supposed to combine something in parentheses, but it doesnโt work ... for some reason it matches things like "]" and "".
Any help would be great :)
Unfortunately, this is part of the exercise, so I can only use the java base library ... It was also intended for regular expression exercises. Am I missing something here?
Moshe source share