08-19-2019 06:52 AM
Hello,
I want to extract the operands from a mathematical formula. I've written the regex in attached the attached snippet.
If one of the operand is BbBb[126] everything is fine (extracted operand = BbBb[126]) , but if the number is BbBb[-126] then I have two operands extracted (BbBb[ and 126]) instead of BbBb[-126]. I cannot figure how to exclude the match of the minus sign if it is between [] while keeping the match of other operators * + / ^ - 😞
The idea of the regex is to find and replace BbBb AaaAA etc by a0, a1 etc. to be compatible with eval formula node.
thank you and best regards.
best regards
Solved! Go to Solution.
08-19-2019 11:36 AM
Just tweak the regex to use a negative look-behind.
(\+|(?<![[])\-|\*|\/|\^)
matches alternatives, either '+', '-' not preceded by '[', '*', '/' or '^'
08-19-2019 11:57 AM
thank you Darin, that solved my problem.
My mind was stuck in trying to find minus operators BETWEEN brackets, while I should just find the opening bracket just BEFORE the minus operator.