|
-
Dec 12th, 2015, 12:18 PM
#3
Thread Starter
Lively Member
Re: RichTextBox Extended Find & Select
 Originally Posted by Edgemeal
If you know what the pre-text and post-text are you can use basic string methods like IndexOf, LastIndexOf to find where that text is located in the string and then use SubString to get just the needed text, there is also RegEx which is best for complicated senerios and is another whole language in itself to learn, and one I picked up many years ago in classic vb using Split, that I still use occasionally, its slow but easy to use,
for example to get Funky Application - 1.0.2 from, SkinVersion{ text=" Funky Application - 1.0.2" shellcmd="" }
you could pass this function the pretext of text=" and post text which is the char " .
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim neededText As String = GetTextBetween(lineOfText, "text=""", """")
MessageBox.Show(neededText)
End Sub
Private Function GetTextBetween(MainText As String, StartText As String, EndText As String, Optional occurance As Integer = 1) As String
If occurance < 1 Then occurance = 1
Try
Return MainText.Split({StartText}, StringSplitOptions.None)(occurance).Split({EndText}, StringSplitOptions.None)(0)
Catch
Return ""
End Try
End Function
Hello Edgemeal, thank you for the reply. Am totally new this... Please explain more of then.
Here is the text file: http://pastebin.com/jmCxzmYF
Thanks.
Tags for this Thread
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
|