6
"hello [world] this is {is} (test)"문자열이 있습니다. 중괄호 안에있는 모든 텍스트를 제거하고 싶습니다. "hello this a"를 반환합니다. 그러나 중괄호가 일치하는 경우에만.
누구나 멋진 솔루션이 있습니까? 괄호 이전모든 종류의 중괄호에서 텍스트 제거
s = Regex.Replace(s, @"\s*?(?:\(.*?\)|\[.*?\]|\{.*?\})", String.Empty);
\s*?
일치 공백 :
중괄호가 일치하지 않는 경우 원하는 동작은 무엇입니까? "this {another another {test}" 중첩은 어떨까요? "{another {test}}"입니다. – Anton