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!
IndexOf returns the position of the first character of the pattern in the host string. You add 1 to your startIndex, which is why the first “!” is not included. Change “+ 1” to “+ 10” (the length of your pattern) and it should work as expected.