I want to have a regex that can detect last math expression in order to change sign of that expression for example :
5 --> -5
-5 --> 5
5+2*cos(10) --> 5-2*cos(10)
5-cos(10+2) --> 5+cos(10+2)
I still couldn't create any regex that can match last expression. I created this regex (\+[(cos|sin|tan)])+(.*[0-9]*.) but it only select the last expression if there is a sin/cos or tan.