我有一個字符串條件性拆分字符串分隔符多
string astring="#This is a Section*This is the first category*This is the
second Category# This is another Section";
我想根據定界符這個字符串分開。如果我在開始時有#這將表明部分字符串(字符串[]部分)。如果字符串將以*開頭,則表明我有一個類別(字符串[]類別)。 因此,我想有
string[] section = { "This is a Section", "This is another Section" };
string[] category = { "This is the first category ",
"This is the second Category " };
我發現這個答案: string.split - by multiple character delimiter 但它不是我想做的事。
看起來像一個正則表達式來我一份工作,使用捕獲組,這應該是在散步公園 –
@SimonRapilly你甚至不需要捕獲組。火柴足夠了。 –
如果你的答案有兩個正則表達式,但如果你想要一個正則表達式,那麼你將需要捕獲組 –