I am trying to write a regex to match math operators to a char. I've tried a bunch of different things but i keep getting:
Syntax error on tokens, Expression expected instead
my code looks like this:
public static void readMath(char c) {
if(c == [+\-*/]) {
// do some stuff
}
}
i've tried escaping different things etc etc. i can't seem to get it to work.
public static void readMath( char c ) {
if ( String.valueOf( c ).matches( "[-+*/]" ) ) {
// do stuff
}
}
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