Well, it's almost that time again; June 1st, 2010 will be the 3rd annual (Inter)?National Regular Expression Day - a celebration of powerful string manipulation! Typically, this day kind of sneaks up on me, so this year I wanted to try and make a bigger todo of it. Regular Expressions are special strings that represent patterns of character data. They can be used to search, replace, and validate text content and happen to be one of the most powerful tools in the developer's toolbox. If you are not familiar with regular expressions, I recommend taking a look at my Intro to Regular Expressions blog post.
| || || || || |
| || |
| || || |
While I haven't read Mastering Regular Expressions, I have read the Regular Expression Cookbook and I have to say that it is simply phenomenal. It was co-authored by Steven Levithan and Jan Goyvaerts. I don't know too much about Jan, but from personal experience, I can tell you that Steven Levithan is a regex genius who has many times sprinkled his pattern-matching expertise over the algorithms presented on this blog.
Micronovae has donated twelve IIS Mod-Rewrite Pro licenses ($150 value per license):
| || || || || |
| || |
| || || |
IIS Mod-Rewrite is a powerful, high quality professional URL rewriting tool for IIS. It rewrites URLs on the fly by using flexible custom rules and helps web developers and webmasters get the most out of their web applications. It is ideal for Search Engine Optimization (SEO), redirecting or proxying requests, blocking undesired traffic and much more. The Pro version is 100% compatible with Apache's mod_rewrite engine; in fact, I use IIS Mod-Rewrite on our production servers and Apache's mod_rewrite in local development with zero configuration changes between the two - it's pretty amazing!
How To Win Cool Regular Expression Prizes
This year, I tried to come with a fun and goofy way to give out prizes. As a passionate and dedicated programmer, I spend most of my time in front of a computer solving problems and doing research; as such, I never got too good at talking to the "ladies." So this year, I built a regular-expression-powered Girl Simulator that will allow me to practice my "moves" from behind the safety and comfort of a computer monitor.
| || || || || |
| || |
| || || |
To enter for a chance to win prizes, you have to add rules to the regular expression engine that powers the Girl Simulator below. Each rule consists of a single pattern and up to three responses. If the given pattern matches an incoming comment (from me), one of the defined responses will be chosen at random and returned. On June 1st, I'll give out prizes based on randomly selected rules in the pattern-matching engine.
Looking For A New Job?
- Mid-Level Developer - Remote at Meeting Play
- Cold Fusion Developer/Designer at BPO Elks of the USA
- 10 year + CF lead Programmer/Developer with expert dot net/sql skills at Atprime Media Services
- ColdFusion Developer (advanced) at Intoria Internet Architects
- Full-time, remote CF Developer for Motorsport SaaS Company at MotorsportReg.com
Does it support subpattern matching in the reponce, ie can I use \1 \2 \3, etc?
Darn, guess not
I didn't even think of that! Right now, it just uses the Java pattern matching engine to see if the match can be found. I'll see if perhaps I can get some more complex logic in there.
Ben, this is the coolest thing ever.. awesome work!
Thanks my man :) Glad you like. Feel free to spread the word.
Ha ha, that's a really good one Ben. I've added some entries.
ironically, although I'm rubbish at regular expressions, when it comes to the ladeez...also rubbish.
Ha ha, so this will be good practice on both fronts ;)
Really funny reg-exp logic Girl!
thanks by the funny time.
FYI, Micronovae has donated 10 *additional* PRO licences for the contest. I will not be giving away 12. Sweeeet!
Hhm, this seems just *wrong* to me! I'm not sure I want to give away the secrets of what women are really thinking. ;-)
Seriously though Ben, you didn't include subpatterns for the responses?? What were you thinking man?!
Help a guy out :)
The sub-pattern replacement would have been cool. I hadn't even considered it when writing the code. The testing and the replace are done in different steps behind the scenes, so it's not even an easy update to make ... actually... maybe there is something I can do. Of course, the validation becomes more complicated as well. Hmmmm.
@Ben - Just read that last comment - so what exactly *are* you doing with all those licenses?? Hoarding them for yourself??? (typos are so fun!)
Oops :) I thought you were referring to the "12" as being a typo. Just re-read it - makes me seem like some sort of sinister criminal... mwwaaha ha ha ha ha!
@Ben - Oh, it's not that big a deal. I was just adding my Trek captain matcher and had some thoughts for replies with the names that would be cute, but it's not like this is mission critical stuff. ;-)
@Ben - yeah, when I first read that, I was like, huh?? He's not giving them away?? I always seem to catch those typos (I often proofread stuff for friends as I catch everything!)
FYI - My name is Mary Jo, not Mary. Many women have two-word first names...and nothing bugs us more than someone leaving off half of it! ;-) I'm assuming you didn't think "Jo" was my last name....
Haha, can't belive you could come up with such an idea Ben! Very...crazy :-P
My reg exp is not very good though. But even before thinking of reg exp, might have to go back and read books about "talking to the ladies" first ;-)
BTW, the O'Reilly books look very compelling to me, thinking of grabbing a copy of them soon.
@Khoa, What I like about the way Ben designed this is that it totally allows the user to work at whatever level of expertise they have. It doesn't at all require more than a very basic level of regex understanding to come up with some entries.
Knowing how to talk to ladies....that may require a tad more expertise. ;-)
If you hit the "Reply" link next to people's names, it auto-fills in the comment box with an "@" style notation; it does this by grabbing the first word - I must have just hit that and forgot to add the "Jo". You and I have had enough emails back and forth for me to know your name ;)
@Ben - Ah, good to know. Yeah, the tech world in particular is not well designed for us two-name folks. I've often run into systems that just absolutely would not accept a first name with spaces in it at all and just ended up writing my name as "MaryJo" to get past that.
Something to think about when writing a regex to parse a name... it's not as easy as it might seem. Then there are the cultures where first and last names are reversed from what we use to make life even more difficult. ;-)
Just to join the "name conversation", my first name is in fact 2 words as well. They are "Vinh Khoa". My last name is Nguyen but I usually just use Vinh Khoa as I prefer to keep it short. Many people don't know that and they just call me Vinh as they think that is my first name :-(
Although I sort of get used to that, Vinh Khoa still sounds a lot nicer to hear when people do know that :-)
My patterns give guys some chances :)
...to encourage optimism in geek lines, whose moral is mowed by the blade of frequent rejection :)))
@Marko - I really chuckled at that note, it's too easy to fall into the pattern of just beating down geeks. Funny, you'd think it might be easier for us geek grrls but I seem to run into as many guys that are not interested in someone with a decent amount of intelligence (or perhaps it's just that I am more than willing to give my opinion and tell them how *wrong* they are on most topics, ha!) as I do those that are fascinated that a girl could know more Star Trek trivia than they do!
@Ben - now that I know the problem with my name pre-filling I can just use the alternate that lots of my family and friends call me by. Makes life easier and I don't have to feel like a twit for correcting anyone on it. ;-)
MJ: You know more star trek trivia then me? That is either incredibly presumptuous or incredibly hot, or both.
@David - well I can't make comparisons that specific, just talking in general. I would *never* presume to impugn a Trekkie's level of trivia knowledge. ;-)
(will|would|want)?.*?(out with me)?
is a bit of a show stopper, maybe take out the optionals from the keywords. Too greedy. :)
Tried to build up a "trap" conversation, but either I made a mistake or the RE above cuts me off.
Anyway, such a lovely idea. Funny too.
Yeah, some of them are a bit greedy in how they match. It's all in good fun, though :)
Ben, so how'd it go improvin your skills with the ladies? Regex girl help you along?
I only got slapped 3 times yesterday - so, definite improvement!!!
What a terrific Regular Expression day! I appreciate all the participation. I have taken the rules and passed them through a random selector to get the following winning patterns.
(?im)(what|are you)?\s?(do you)?\s?(do|doing|free)?\s*(tonight|today|tonite)
(D|d)o you (like|want) this (site|website)?
are.+?(u|you) going to (SOTR|(s|S)cotch (O|o)n the (R|r)ocks|(S|s)cotch)
.... I'll be sending out an email to see what people want. I only have a few books to give away and a bunch of IIS Mod-Rewrite licenses so I'll just take the email responses as I get them.
Thanks so much to everyone who participated! It was a grand day indeed, worthy of the beauty that is the Regular Expression!
Just wanted to say, kudos on running a fantastic contest, it was a lot of fun, and even more so reading through all the entries and figuring out what they were trying to match on. And I'd say that even if I wasn't one of the lucky winners. ;-)
I am one the lucky winners and owe gratitude to Ben for organizing so fun event. Thank you.
Looking at the expressions/responses was really a blast (except for a few really dark ones) - a great idea!
I think my favorite response was 'I only date Ruby devs'.