我将整个文本放在名为" Str"
的字符串中我需要找到这样的任何字符串(它可以是整行或一个单词)
文本
我可以使用正则表达式或拆分吗?需要一些帮助来理解这一点。
答案 0 :(得分:1)
你可以这样做:
Dim startIndex, endIndex As Integer
mystring = "Hello there, I'm [Here] to answer all the [questions that you can ask] Can I return two [strings] only from this string Here and questions that you can ask"
While mystring.Contains("[") Or mystring.Contains("]")
startIndex = mystring.IndexOf("[") + 1
endIndex = mystring.IndexOf("]") - startIndex
MessageBox.Show(mystring.Substring(startIndex, endIndex))
mystring = mystring.Substring(mystring.IndexOf("]") + 1)
End While