I'm building a parser for formulas, I'm having troubles with nested brackets, is there a simple regex to solve this kind of expressions considering an indefinite amount of nesting?
This is how the expression are composed:
If(Condition) Then { Action } Else { Action2 }
Example of expressions:
1: if (Category = 4) then {Validation(HB):Insert(COMNP)} else {Nothing}
2: if (Requested(INDP)) then { if (Result(INDP) > 70) then { DoNothing } else { MakeSomething } else { MakeSomethingElse }
Example of return:
1: if (Category = 4) then {return 1;} else {return 2;}
2: if (Requested(INDP)) then { if (Result(INDP) > 70) then { return 1; } else { return 2; } else { return 3;}
With match arrays like this:
[1]: Validation(HB):Insert(COMNP)
[2]: Nothing
[1]: DoNothing
[2]: MakeSomething
[3]: MakeSomethingElse
My RegEx knowledge isn't strong but I know this is achievable in some way, I hope my post is easy to understand.
I need to isolate the actions between the deeper brackets and replace them with ordered numbers.