Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用正则表达式在一组括号内提取一系列文本 - 特别是当这些括号本身嵌套在一组或多组括号内时。例如:
输入:
_t("someText (I don't want to wear pajamas.)")
输出:
(I don't want to wear pajamas.)
你可以使用这个正则表达式
\([^()]*\)
List<string> output=Regex.Matches(input,aboveRegex) .Cast<Match>() .Select(x=>x.Value) .ToList();