Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the last occurrence of a set of characters from a string

Tags:

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.