diff options
-rw-r--r-- | order_of_operations_parser.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/order_of_operations_parser.php b/order_of_operations_parser.php index f4525db..9382497 100644 --- a/order_of_operations_parser.php +++ b/order_of_operations_parser.php @@ -77,7 +77,7 @@ for (i=0;i<=$numRecords;i++) //contains addition - $regexp = "+"; + $regexp = "/\+/"; if (preg_match($regexp, $equation)) //if ($tok[2] contains TODO check for correctness { $contains_addition[tok[0]]++; //but is not correct @@ -108,7 +108,7 @@ for (i=0;i<=$numRecords;i++) //TODO: account for negative numbers //contains subtraction - $regexp = "-"; //NOTE:operation remains the same, as we are checking it four times for each operation + $regexp = "/[0-9]\-[0-9]/"; //NOTE:operation remains the same, as we are checking it four times for each operation if (preg_match($regexp, $equation)) { $contains_subtraction[tok[0]]++; @@ -132,7 +132,7 @@ for (i=0;i<=$numRecords;i++) //******************************DIVISION******************************** //contains division - $regexp = "\/" + $regexp = "/\//" if (preg_match($regexp, $equation)) { $contains_division[tok[0]]++ @@ -157,7 +157,7 @@ for (i=0;i<=$numRecords;i++) //**************************************Multiplication************************* - $regexp = "*" //Matches equations with only multiplication + $regexp = "/\*/" //Matches equations with only multiplication if (preg_match($regexp, $equation)) { $contains_multiplication[tok[0]]++; |