【发布时间】:2017-04-11 17:54:24
【问题描述】:
给定一个字符串...
M0 Apple Sauce M1 Peanut Butter M2 Porcupine M3 Quesadilla M4 Margarita
我怎么能把那个字符串分成..
M0 Apple Sauce
M1 Peanut Butter
M2 Porcupine
M3 Quesadilla
M4 Margarita
有没有办法将M0, M1,..., M4 放入一个数组中,然后使用该数组来拆分字符串?
【问题讨论】:
-
更好,使用正则表达式 -
Regex.Split(s, "(?!^)(?=\bM\d+\b)")。 -
@WiktorStribiżew 我刚刚读到这个,你能用我上面的例子举个例子吗?
-
您在寻找什么样的输出? (例如,具有 2 列、1 列或字符串数组的 DataTable?)
-
参见this demo,拆分列表。
-
刚刚测试了 Wiktor 的正则表达式字符串,效果很好。
标签: arrays string vb.net list split