html tag matcher using array stack