I want to create a function where you check if a string contains only 0-9 /+*-{} (space) chars. This is similar to google’s calculator query check.
function is_calculation($str) {
if (???) {return true;}
return false;
}
it needs to be something like /[0-9 *-/+ [] {} () ]/
if (preg_match('/^[0-9\ \*\/\+\[\]\{\}\(\)\ -]+$/',$str)) {