C# regex for matching sepcific text inside nested parentheses
问题 I have these code lines for take to operators between parentheses: string filtered = Regex.Replace(input, "\\(.*?\\)", string.Empty); var result = filtered.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Where(element => element == "OR" || element == "AND"); string temp = string.Join(" ", result); These lines do not work for nested parentheses. For example; it is working for this input : X1 OR ( X2 AND X3 AND X4 AND X5 ) OR X6 It give me this result: OR OR But, when my input has