【问题标题】:Parse strings between delimiters into an array将分隔符之间的字符串解析为数组
【发布时间】:2013-06-30 13:34:48
【问题描述】:

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

[hellothere1241 伙计 omg what][多少 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

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

【问题讨论】:

    标签: vb.net string get


    【解决方案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)
    

    【讨论】:

      猜你喜欢
      • 2012-10-23
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      • 2016-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-29
      相关资源
      最近更新 更多