0

C# で見たように、ステートメントは { } のように中かっこの中にあります。[[ ]] これらの中に複数の文字列を含む文字列がある場合はどうなるでしょうか。

入出力例:

string s = "this is the string I am talking about [[and the text inside]] but don't      forget about other [[ones like this]].";

string[] insideBrackets;

insideBrackets[0] will be **and the text inside**
insideBrackets[1] will be **ones like this**

ところで、私は文字列分割とindexOfを持っていますが、私が望むほどうまく機能していません。答えてくれた人に感謝します。これが良い質問として高く評価されることを願っています:)

4

1 に答える 1

9

これに使えますRegex

string s = "this is the string I am talking about [[and the text inside]] but don't      forget about other [[ones like this]].";

var insideBrackets = Regex.Matches(s, @"\[\[(.+?)\]\]").Cast<Match>()
                        .Select(m => m.Groups[1].Value)
                        .ToArray();
于 2013-06-01T19:26:46.923 に答える