0

我有一个这样的字符串输入:

[hellothere1241 伙计 omg 什么][多少 tiasf sgasgag][gas adgh adh sdgsd gsd][gsdgsdgsdg sd sdgsdgsgsd ga21451t][t13g1gsd s]

我需要将每个 [ 和 ] 之间的所有字符串都放入这样的数组中:

hellothere1241 fellow omg what
how many tiasf sgasgag
gas adgh adh sdgsd gsd
gsdgsdgsdg sd sdgsdgsgsd ga21451t
t13g1gsd s

谁能给我一个例子?提前致谢!

4

1 回答 1

1

您可以使用此答案中提到的正则表达式。VB.NET 等价物是

Dim pattern = "\[(.*?)\]"
Dim query = "[hellothere1241 fellow omg what][how many tiasf sgasgag][gas adgh adh sdgsd gsd][ gsdgsdgsdg sd sdgsdgsgsd ga21451t ][t13g1gsd s]"
Dim matches = Regex.Matches(query, pattern)
于 2013-06-30T13:40:14.713 回答