|
-
Dec 12th, 2009, 01:38 AM
#1
Thread Starter
Lively Member
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.
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?
-
Dec 12th, 2009, 02:08 AM
#2
Re: Richtextbox instance of string search
i don't understand the question
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 12th, 2009, 02:46 AM
#3
Thread Starter
Lively Member
Re: Richtextbox instance of string search
 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?
-
Dec 12th, 2009, 02:59 AM
#4
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 12th, 2009, 03:10 AM
#5
Thread Starter
Lively Member
Re: Richtextbox instance of string search
I've added the code in a button but no msgbox that appears.
-
Dec 12th, 2009, 03:12 AM
#6
Re: Richtextbox instance of string search
can you post an example of RichTextBox1.Text?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 12th, 2009, 03:26 AM
#7
Thread Starter
Lively Member
Re: Richtextbox instance of string search
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
-
Dec 12th, 2009, 03:27 AM
#8
Thread Starter
Lively Member
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?
-
Dec 12th, 2009, 04:09 AM
#9
Re: Richtextbox instance of string search
different regex:
vb Code:
Dim rx As New Regex("(?<=Dim\s).+?(?=\b)")
it'll return local variables + arrays
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 12th, 2009, 04:19 AM
#10
Thread Starter
Lively Member
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..
-
Dec 12th, 2009, 04:37 AM
#11
Re: Richtextbox instance of string search
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 12th, 2009, 04:56 AM
#12
Thread Starter
Lively Member
Re: Richtextbox instance of string search
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
|