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:
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>
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
Code:
11108[1-7]
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?
Very Good Job Jason. Saved us from most of the regex shit. /thanked =)
Edit:
Credits: Hassan for being a pedo.
/FP
Originally Posted by Hassan
Very Good Job Jason. Saved us from most of the regex shit. /thanked =)
Not a problem 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)
Noez no credit for me :[
Looks awesome btw, can't wait to test it :P
Originally Posted by Blubb1337
Noez no credit for me :[
You blind nigga?
Originally Posted by Blubb1337
Noez no credit for me :[
/QUOTE]
You blind nigga?
Why ya in so hurry son ? (Watch the tags)
Originally Posted by Jason
You blind nigga?
Last edited by Jason; 7 Minutes Ago at 10:37 AM..
Originally Posted by Blubb1337
Last edited by Jason; 7 Minutes Ago at 10:37 AM..
For a different reason
Warning on the obfuscation, approved however.
Originally Posted by Lolland
Warning on the obfuscation, approved however.
Oh woops, forgot I obfuscated it. Been getting into the habit of obfuscating lately. Trust me on it?
Obfuscation, or "anti-lolland" as it is commonly known, is the concealment of intended meaning in communication, making communication confusing, intentionally ambiguous, and more difficult to interpret.
Basically makes the source unintelligible when someone tries to reflect it. Throw in some string encryption and a NecroBit and it's near impossible to reflect back