2013-06-30 133 views
0

我有一个字符串输入是这样的:解析字符串到一个数组

[hellothere1241同胞OMG什么] [多少tiasf sgasgag] [气体adgh ADH sdgsd GSD] [gsdgsdgsdg SD sdgsdgsgsd ga21451t] [t13g1gsd秒]

我需要把所有各[和]之间的字符串像数组:

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

谁能给我一个例子吗? 在此先感谢!

回答

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) 
+0

谢谢,作品justl ike魅力 –

+0

不客气:) – keyboardP