Code Fragment 6.4: Function for matching delimiters in an arithmetic expression.