1
如何使用正則表達式在一組圓括號內提取一系列文本 - 具體而言,當這些括號本身嵌套在一組或多組括號內時。例如:選擇嵌套在其他括號內的內部圓括號
輸入:
_t("someText (I don't want to wear pajamas.)")
輸出:
(I don't want to wear pajamas.)
如何使用正則表達式在一組圓括號內提取一系列文本 - 具體而言,當這些括號本身嵌套在一組或多組括號內時。例如:選擇嵌套在其他括號內的內部圓括號
輸入:
_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();
完美 - 謝謝。 –
請發佈您的問題/代碼的問題。另外,閱讀[關於如何提問的常見問題](http://stackoverflow.com/help/how-to-ask)。 – Jerry