0

私はこの線の文字列を持っているとしましょう:

'''Sir Winston Leonard Spencer-Churchill''', {{Post-nominals|post-noms=[[Knight of the Garter|KG]]

コードで空の結果を使用せずに文字列分割を使用するようになりましたが、その文字列の結果は次のようになります。

[0] "'''"
[1] 「サー・ウィンストン・レナード・スペンサー・チャーチル」
[2]「'''」
[3]「、」
[4]「{{」
[5] "ポスト名|ポスト名="
[6]「[[」
[7]「ガーターの騎士|KG」
[8]「]]」

などなど、基本的に私の区切り記号は{"'''","{{","}}","[[","]]"} その方法が必要なだけです。後で編集します。正規表現を使用しない場合は、より良いでしょう。

4

2 に答える 2

3

使用Regex:

string input = "'''Sir Winston Leonard Spencer-Churchill''', {{Post-nominals|post-noms=[[Knight of the Garter|KG]]";
string pattern = @"('''|\{\{|\}\}|\[\[|\]\])";
string[] result = Regex.Split(input, pattern);
于 2013-01-10T17:20:11.427 に答える
0

この正規表現を使用する(?<=^?'''|\{\{|\[\[|\]\]|\}\})(.+?)(?=$?'''|\{\{|\[\[|\]\]|\}\})

于 2013-01-10T17:23:44.590 に答える