String Manipultation - Get String between two other Strings?
- by Ben
I have a large piece of text in which there is something simular to this:
!#_KT_#!COMMANDHERE!#_KT_#!
I want, in VB.Net, to get the 'COMMANDHERE' part of the string, how would I go about doing this? I have this so far:
Dim temp As String = WebBrowser1.Document.Body.ToString
Dim startIndex As Integer = temp.IndexOf("!#__KT__#!") + 1
Dim endIndex As Integer = temp.IndexOf("!#__KT__#!", startIndex)
Dim extraction As String = temp.Substring(startIndex, endIndex - startIndex).Trim
TextBox1.Text = extraction
However this only removes the LAST string eg: #_KT_#! COMMAND.
Any help is appreciated!