我需要用分号 ( ;
) 作为分隔符来分隔字符串。括号内的分号应该被忽略。
例子:
string inputString = "(Apple;Mango);(Tiger;Horse);Ant;Frog;";
字符串的输出列表应该是:
(Apple;Mango)
(Tiger;Horse)
Ant
Frog
其他有效的输入字符串可以是:
string inputString = "The fruits are (mango;apple), and they are good"
上面的字符串应该拆分成一个字符串
"The fruits are (mango;apple), and they are good"
string inputString = "The animals in (African (Lion;Elephant) and Asian(Panda; Tiger)) are endangered species; Some plants are endangered too."
上面的字符串应该分成两个字符串,如下所示:
"The animals in (African (Lion;Elephant) and Asian(Panda; Tiger)) are endangered species"
"Some plants are endangered too."
我搜索了很多,但找不到上述场景的答案。
有谁知道如何在不重新发明轮子的情况下实现这一目标?