I'm trying to find the last operator (+
, -
, *
or /
) in a string.
I was trying to use the method string.indexof('operator', i);
, but in this case I could only get the single type of operator
. Is there any better solution for this?
The value of string
could, for example, be:
1+1/2*3-4
or
1/2-3+4*7
It means the last operator could be any of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With