|
-
Feb 8th, 2010, 12:40 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] RegEx with VB.NET
I am creating a program to search a specific website's HTML source code for a very specific URL string structure with two variable areas in it. I am not good with these regular expressions at all and am having trouble getting what I need.
Here is what I have so far in VB.NET:
Code:
Dim testNum As MatchCollection = Regex.Matches(TextBox1.Text, "<a href='series.php\?ID=[0-9]'>[^</a>]</a>")
If testNum.Count = 0 Then
End
Else
MessageBox.Show(testNum.Count)
End If
Expression: <a href='series.php\?ID=[0-9]'>[^</a>]</a>
Sample Text:
<a href='series.php?ID=23'>Aishiteru ze Baby ( Love You Baby )</a>
<a href='series.php?ID=230'>Akage no Anne ( Anne of Green Gables )</a>
There is an ID number that is variable in Integer value and length directly after "ID=".
Between the HTML anchor tags, there is variable text that can have any length and any characters.
I run my code and no values are being returned (The count of the Match collection is 0).
I know my code is correct because if I just do a search for a single character, I get results. ("a" = 14 matches)
So, I'm totally lost and have no idea what is wrong with my expression as, for some reason, I am totally not grasping this RegEx thing entirely and what constitutes an illegal expression. I'm not sure if it's wrong, or if it isn't compatible with VB.NET or if it's totally wrong. I used a RegEx creator program (which is where I got the above expression), and I'm not even sure if I was operating it properly and if the expression it gave me is right.
Thanks for any help provided.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
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
|