我有一个像这样的字符串输入:
[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
有谁能举个例子? 提前谢谢!
答案 0 :(得分:1)
您可以使用this answer中提到的正则表达式。 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)