Is there a way of checking for multiple string sequences with String.matches in Java?

45 Views Asked by At

I want to look for any of the following sequences: either one of * - / + followed by a * + /

for example: 4+*2 is something I am looking for. 4+5/2 is not

if (combinedArray.matches("[-*+/][*+/]"))
{
...code
}

I'd be happy to know what I did wrong.

I basicly want it to have the same logic as this:

if (combinedArray.contains("*/") | combinedArray.contains("*+") | combinedArray.contains("**") 
        | combinedArray.contains("//") | combinedArray.contains("/+") | combinedArray.contains("/*") 
        | combinedArray.contains("+/") | combinedArray.contains("++") | combinedArray.contains("+*") 
        | combinedArray.contains("-/") | combinedArray.contains("-+") | combinedArray.contains("-*") )
~~~
0

There are 0 best solutions below