|
-
Aug 10th, 2009, 09:32 AM
#11
Thread Starter
Hyperactive Member
Re: Get the string in the middle?
 Originally Posted by stanav
As Negative0 already suggested, if you don't wnat to use regex, you can use the string.indexof function. Something like this:
Code:
Dim startText As String = "whatever the start text here"
Dim endText as string = "whatever the end text here"
Dim sourceText as string = "the string you want to search from here"
Dim startIndex as integer = sourceText.IndexOf(startText)
Dim textInBetween As String = "Not found"
If startIndex >= 0 Then
sourceText = sourceText.SubString(startIndex)
If sourceText.IndexOf(endText) > 0 Then
textInBetween = startText.Substring(0, sourceText.IndexOf(endText))
End If
End If
MessageBox.Show(textInBetween)
That's giving me
Index and length must refer to a location within the string. Parameter name: length
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|