[Release]RegEx Extraction Pattern Gen [BETA]
Hey guys, as the title says, this is simply a BETA release to check for bugs and the like.
What does it do?
Basically, you put in a string containing some information you want, but it's surrounded by useless crap you don't want. Next, you fill in what you want out of that string. Finally, if there are any variable sections in the code (i.e the URL is dynamic and changes every time) you add each of them to a separate line in the appropriate textbox. Last but not least, press "Generate Regular Expression" to get your RegEx.
Why the f*** do i need this sh**? I hate you
Well, say you have a webpage to parse (for example) and regular string manipulation methods are failing dismally (they can't handle the dynamic nature of the URLs), well now you get to use some RegEx to get those unobtainable values!
Okay..I got this "RegEx" nao wut?
Okay now it's time to bring it back to VB. Firstly you need to import RegEx like so:
[php]
Imports System.Text.RegularExpressions
[/php]
Next you define your pattern (Copy and paste the value in the last textbox from my program)
[php]
Dim myAwesomePattern As String = "(?<=\./memberlist\.php\?mode=viewprofile&u=)\d{0,7}(? ="">)"
Dim mCollect As MatchCollection = Regex.Matches("inputstring", myAwesomePattern)
For each m as match in mCollect
MsgBox(m.Value)
Next
[/php]
And voila it will give you all the matches in a given string (you'll need to change input string)
Okay, here's a practical example that I was asked to do the other day from someone on another site.
I was given this string:
And asked if I could write a RegEx to extract the people's names only. (this was an extract from a larger string)
So, say I was to use my Pattern generator here, I would simply grab one of these lines:
And put it straight in the first textbox. Now, obviously I want to extract the name "doom", so in the second field I write "doom"
Now, the variable section. As you can see, the number preceding the name (the profileID in this case) is different for each user...i.e it is VARIABLE. So where do I put it? You guessed it, the variable section.
Now, in the string i chose, the profileID was 11108, so I put that in the variable box. In this case I am going to define a length. As this is a member number, it's logical that it started at 1, and I'll make it go up to 7 characters maximum (in case the website grows by a large amount)
I put this in the variable textbox
Now i'm ready to generate, as I have no other variables. Hit the generate button and look what popped out!:
So now I define this as my pattern as before (in the case of doublequotes, two double quotes in a row in the compiler represent a single double quote in string (i.e typing MsgBox("This""a""b") will show This"a"b)
[php]
Dim Names As MatchCollection = Regex.Matches(myStr, "(?<=<a href="\./memberlist\.php\?mode=viewprofile&u=\d{1,7}""> )\w+(?=</a>)")
[/php]
And loop through the match collection, as before, to get all the names. Easy eh?
Here's a screenshot:

Now for the scans:
VirusTotal 0%
VirSCAN 0%
And that's all from me.
Credits -
Me for all the coding and shit.
Hassan for being a pedo.
Kevin for being a babe.
Cheers guys,
Jason
What does it do?
Basically, you put in a string containing some information you want, but it's surrounded by useless crap you don't want. Next, you fill in what you want out of that string. Finally, if there are any variable sections in the code (i.e the URL is dynamic and changes every time) you add each of them to a separate line in the appropriate textbox. Last but not least, press "Generate Regular Expression" to get your RegEx.
Why the f*** do i need this sh**? I hate you
Well, say you have a webpage to parse (for example) and regular string manipulation methods are failing dismally (they can't handle the dynamic nature of the URLs), well now you get to use some RegEx to get those unobtainable values!
Okay..I got this "RegEx" nao wut?
Okay now it's time to bring it back to VB. Firstly you need to import RegEx like so:
[php]
Imports System.Text.RegularExpressions
[/php]
Next you define your pattern (Copy and paste the value in the last textbox from my program)
[php]
Dim myAwesomePattern As String = "(?<=\./memberlist\.php\?mode=viewprofile&u=)\d{0,7}(? ="">)"
Dim mCollect As MatchCollection = Regex.Matches("inputstring", myAwesomePattern)
For each m as match in mCollect
MsgBox(m.Value)
Next
[/php]
And voila it will give you all the matches in a given string (you'll need to change input string)
Okay, here's a practical example that I was asked to do the other day from someone on another site.
I was given this string:
Code:
<span class="genmed">In total there are <strong>34</strong> users online :: 9 registered, 11 hidden and 14 guests (based on users active over the past 5 minutes)<br>Most users ever online was <strong>206</strong> on Mon Apr 24, 2006 2:57 pm<br><br>Registered users: <a href="./memberlist.php?mode=viewprofile&u=15410">1984</a>, <a href="./memberlist.php?mode=viewprofile&u=11702">Damon</a>, <a href="./memberlist.php?mode=viewprofile&u=11108">doom</a>, <a href="./memberlist.php?mode=viewprofile&u=11681">Festerban</a>, <a href="./memberlist.php?mode=viewprofile&u=15784">interpol</a>, <a href="./memberlist.php?mode=viewprofile&u=15166">LOLDONGS</a>, <a href="./memberlist.php?mode=viewprofile&u=4981">mi5</a>, <a href="./memberlist.php?mode=viewprofile&u=15137">MOOT</a>, <a href="./memberlist.php?mode=viewprofile&u=5153">timebomb</a></span>
So, say I was to use my Pattern generator here, I would simply grab one of these lines:
Code:
<a href="./memberlist.php?mode=viewprofile&u=11108">doom</a>
Now, the variable section. As you can see, the number preceding the name (the profileID in this case) is different for each user...i.e it is VARIABLE. So where do I put it? You guessed it, the variable section.
Now, in the string i chose, the profileID was 11108, so I put that in the variable box. In this case I am going to define a length. As this is a member number, it's logical that it started at 1, and I'll make it go up to 7 characters maximum (in case the website grows by a large amount)
I put this in the variable textbox
Code:
11108[1-7]
Code:
(?<=<a href="\./memberlist\.php\?mode=viewprofile&u=\d{1,7}">)\w+(?=</a>)
[php]
Dim Names As MatchCollection = Regex.Matches(myStr, "(?<=<a href="\./memberlist\.php\?mode=viewprofile&u=\d{1,7}""> )\w+(?=</a>)")
[/php]
And loop through the match collection, as before, to get all the names. Easy eh?
Here's a screenshot:

Now for the scans:
VirusTotal 0%
VirSCAN 0%
And that's all from me.
Credits -
Me for all the coding and shit.
Hassan for being a pedo.
Kevin for being a babe.
Cheers guys,
Jason
RegEx Pattern Gen.zip


I think I'll continue writing them manually though, to stay in practice. But it will be a good reference if I forget some stupid shit (like canceling metacharaters /fp2)
(Watch the tags)


