|
-
Jun 4th, 2009, 04:45 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Regex help!
-
Jun 4th, 2009, 08:47 AM
#2
Addicted Member
Re: Regex help!
Check out somewhere like www.regexlib.com (also /cheatsheet.aspx)
There is a handy tester there and there are also a fair few examples.
I'm far from an expert in Regex but I think you should be looking for the text pattern you want rather than finding the start and end of the pattern. This is what I use to pick out repeating strings from other text
Code:
Dim rx as New Regex("pattern")
For Each m As Match In rx.Matches("the text to check")
DoSomething = m.Value
Next
-
Jun 4th, 2009, 10:48 AM
#3
Re: Regex help!
try this:
vb Code:
Dim rx As New Regex("(?<=TITLE: </b> ).+?(?=<o:p></o:p></span></p>)")
MsgBox(rx.Match(testStr).Value)
heres a regex tutorial + a regex reference site
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 4th, 2009, 02:13 PM
#4
Hyperactive Member
Re: Regex help!
 Originally Posted by .paul.
try this:
vb Code:
Dim rx As New Regex("(?<=TITLE: </b> ).+?(?=<o:p></o:p></span></p>)")
MsgBox(rx.Match(testStr).Value)
heres a regex tutorial + a regex reference site
Hey, Paul, I got that to work, and I've been trying to figure out RegEx for some time, do you think you could kinda explain how each part works? I want to know how to match something in between two things. I can't figure it out. Please help.
Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out. 
-
Jun 4th, 2009, 02:27 PM
#5
Re: Regex help!
(?<=pattern) = find before specified string (next part)
.+ = at least 1 char (any char = .) (at least 1 char = +)
? = specifies find smallest possible string that matches
(?=pattern) = find after specified string (middle part)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 4th, 2009, 02:35 PM
#6
Re: Regex help!
Download the free Expresso regex tool and play with it.
http://www.ultrapico.com/Expresso.htm
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jun 4th, 2009, 02:59 PM
#7
Hyperactive Member
Re: Regex help!
 Originally Posted by stanav
I decided to make one of my own really quick, so if the match I want to find is
"bunny" in "The purple bunny went hopping through the forest" what would my regular expression be?
Edit: also, I want to pretend I don't know the word is bunny.
Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out. 
-
Jun 4th, 2009, 03:02 PM
#8
Re: Regex help!
Dim rx As New Regex("(?<=The purple ).+?(?= went hopping through the forest)")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 4th, 2009, 03:17 PM
#9
Hyperactive Member
Re: Regex help!
 Originally Posted by .paul.
Dim rx As New Regex("(?<=The purple ).+?(?= went hopping through the forest)")
Thanks, that helps a lot.
The only thing I need to know now is how to put all matches in a listbox. Can you tell me how to do that?
Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out. 
-
Jun 4th, 2009, 03:28 PM
#10
Re: Regex help!
vb Code:
Dim rx as New Regex("pattern")
For Each m As Match In rx.Matches("the text to check")
listbox1.items.add(m.Value)
Next
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 4th, 2009, 04:24 PM
#11
Hyperactive Member
Re: Regex help!
 Originally Posted by .paul.
vb Code:
Dim rx as New Regex("pattern")
For Each m As Match In rx.Matches("the text to check")
listbox1.items.add(m.Value)
Next
Thanks for helping me with RegEx .paul.
rep+
Sorry if my posts are misleading or sometimes rude, I'm just trying to get information so try to help me out. 
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
|