func isValid(code string) bool { st := make([]string, 0) for i := 0; i < len(code); i++ { if 0 < i && len(st) == 0 { // Unmatched content return false } if strings.HasPrefix(code[i:], "") if j < 0 { return false } i += j + 11 } else if strings.HasPrefix(code[i:], "") if j < 0 { return false } name := code[i : i+j] if l := len(st); l == 0 || st[l-1] != name { return false } else { st = st[:l-1] } i += j } else if code[i] == '<' { // Parse begin i += 1 j := strings.Index(code[i:], ">") if j < 1 || 9 < j { return false } name := code[i : i+j] for _, r := range name { if r < 'A' || 'Z' < r { return false } } st = append(st, name) i += j } } return len(st) == 0 }