determines if the brackets in a string are balanced