String Manipultation - Get String between two other Strings?
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-04-25T11:53:49Z
Indexed on
2010/04/25
12:13 UTC
Read the original article
Hit count: 609
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!
© Stack Overflow or respective owner