Richtextbox instance of string search
I want to get a string from the richtextbox but here how it goes
in programming for example i want to get all class/function and variable names in this given code.
Quote:
Private Function Processstring(ByVal strin As String) As String
Dim astrWords As String() = New String() {"parrot"}
Dim strOut As String = strin
Dim strWord As String
For Each strWord In astrWords
If strin.indexOf(strWord, 0) >= 0 Then
strOut = strWord
Exit For
End If
Next
Return strOut
End Function
how would i get the "processstring" by getting it after the word function?
Re: Richtextbox instance of string search
i don't understand the question
Re: Richtextbox instance of string search
Quote:
Originally Posted by
.paul.
i don't understand the question
I'm creating a texteditor and i want to copy all the function names that will be added in the richtextbox.
how would i search for all the function names in the richtextbox if their would be many functions in it?
Re: Richtextbox instance of string search
you could use regex:
vb Code:
Dim rx As New Regex("(?<=(Function|Sub)\s).+?(?=\()")
For Each m As Match In rx.Matches(RichTextBox1.Text)
MsgBox(m.Value)
Next
don't forget to import regex:
vb Code:
Imports System.Text.RegularExpressions
Re: Richtextbox instance of string search
I've added the code in a button but no msgbox that appears.
Re: Richtextbox instance of string search
can you post an example of RichTextBox1.Text?
Re: Richtextbox instance of string search
Quote:
Private Function Processstring(ByVal strin As String) As String
Dim astrWords As String() = New String() {"parrot"}
Dim strOut As String = strin
Dim strWord As String
For Each strWord In astrWords
If strin.indexOf(strWord, 0) >= 0 Then
strOut = strWord
Exit For
End If
Next
Return strOut
End Function
just like that.. from that i will be expecting the function name: Processstring
Re: Richtextbox instance of string search
i retried it and it work.. thanks for all.. another one is how about getting variablenames after the dim?
Re: Richtextbox instance of string search
different regex:
vb Code:
Dim rx As New Regex("(?<=Dim\s).+?(?=\b)")
it'll return local variables + arrays
Re: Richtextbox instance of string search
wow! thanks.. do you have any software making the regular expressions?
I'd like also to create regex for c++ variables and functions..
Re: Richtextbox instance of string search
Re: Richtextbox instance of string search
gee thanks lot bro.:thumb::D:D:bigyello::bigyello: