June 1st 2008 - National Regular Expression Day! (Post A Comment, Win A Prize)

Posted May 28, 2008 at 10:01 AM

NOTE: To win prizes, you must post a comment below (and mention which prize you would be interested in).

Not so long ago, I was walking down 14th street in New York City when out of no where, I started to think about Regular Expressions. They are just so awesome. I actually took a moment out of my walk home to stop and think about how much they have made my life better. That might seem like a silly notion to those who have not yet used regular expressions, but I think, to those of you who have used them, this feeling might not be so foreign. Everyday might be a bit of a stretch, but I certainly use regular expression every single week in my work; and, I'm finding new ways to leverage regular expressions all the time.

Regular Expressions are so awesome that I wanted to find a way to really give them their moment in the sun. And so, I am hereby announcing the first ever National Regular Expression Day on Sunday, June 1st, 2008. I'd like this to be a day where people take some time to reflect on how useful regular expressions are. And, if you haven't yet used regular expressions, this would be a great day to maybe set aside some time and finally see what all the hubbub is about.


 
 
 

 
National Regular Expression Day - June 1st, 2008 - Brought To You By Ben Nadel & Kinky Solutions  
 
 
 

And, what national holiday would be complete without some cool prizes and give-aways? To be honest, originally, I wanted to do something cool where people got to flex their Regular Expression muscles, but I have been way too busy lately to really devote a lot of brain power to that. So, as an easy way to enter the give aways, all you have to do is post a comment below (before June 2nd) on how much you like regular expressions and what prize you would be interested in winning. Winners will be selected Monday, June 2nd, 2008. And, what can you win, you ask? Some of the following regular expression related goodies:

1) Shakespeare RegEx Shirt


 
 
 

 
National Regular Expression Day - 2008 - Shakespeare TShirt  
 
 
 

2) xkcd RegEx Shirt


 
 
 

 
National Regular Expression Day - 2008 - XKCD TShirt  
 
 
 

3) RegexBuddy License


 
 
 

 
National Regular Expression Day - 2008 - RegexBuddy License  
 
 
 

4) Mastering Regular Expressions


 
 
 

 
National Regular Expression Day - 2008 - Mastering Regular Expressions  
 
 
 

5) Sams Teach Yourself Regular Expressions in 10 Minutes


 
 
 

 
National Regular Expression Day - 2008 - Sams Teach Yourself Regular Expressions In 10 Minutes  
 
 
 

Good luck, and I hope this is fun for people. And remember, win or lose, if you use Regular Expressions, you are always a winner :)

Comments (94)  |  Post Comment  |  Ask Ben  |  Permalink  |  Print Page




Adobe ColdFusion 8.0.1 Update - Helping Programmers To Be Signifanctly Less Girlie - Download ColdFusion 8 Update 8.0.1 Now.

Reader Comments

Hey, Ben,

Not to throw a wrench into things, but why not make this...umm...unique holiday an international affair? Isn't RegEx an international language? :)

Posted by Brian Swartzfager on May 28, 2008 at 10:24 AM


@Brian,

Cut me some slack - it's the first holiday I have ever created :) But yeah, it can be international.

Posted by Ben Nadel on May 28, 2008 at 10:27 AM


LOL

Posted by John Allen on May 28, 2008 at 10:42 AM


Regex rocks!

Posted by Bob Clingan on May 28, 2008 at 11:01 AM


That XKCD shirt is great! I began writing my own regular expressions at my blog, as I kept finding them useful, and forgot to add snippets in Eclipse for them. Certainly an easier way to keep track of them. I have (slight) programmer's OCD, and like my code a certain way, so I ended up writing my own CF page that goes through my old CF code (that was not formatted correctly) and rewrites it with corrected spacing and upper/lowercasing, using RegEx to make all of the find/replaces. Certainly much easier than going through by hand and doing it (my OCD isn't *that* bad :) )

Posted by Gareth Arch on May 28, 2008 at 11:11 AM


The book "Mastering Regular Expressions" by Jeffrey Friedl is the book which I would choose if I could keep only one.

I wrote a review of it on my blog, but I feel like I try to plug myself too often here, so I won't link it - though it shouldn't be too hard to find if you follow the link on my name =).

Posted by Eric on May 28, 2008 at 11:11 AM


Also, that shirt is cute, but it's always bothered me as it reads "2 B's or Not B twice" - Argh, urge to regex rising!

This is better:
/(?=bb)|(?!bb)/

Or if it needs to consume/capture (since (?=...) and (?!...) are non-consuming look-aheads):
/(?:(?=bb)|(?!bb))(..)/

PLUS! maybe it should end in /i so that it's case insensitive!

Sed/vi:
s/(?:(?=bb)|(?!bb))(..)/The question is \1/ig

Aah, there, nerdiness satisfied.

Posted by Eric on May 28, 2008 at 11:22 AM


@Eric,

Ha ha ha :) Awesome.

Posted by Ben Nadel on May 28, 2008 at 11:25 AM


I thought I was odd organising an National (now international) Shed week, but without Regular Expression my CF shed site could not run.

Posted by uncle wilco on May 28, 2008 at 11:29 AM


If I were to use Regex Buddy, which variation of Regex would I select for Coldfusion? Does it use the Java version?

Posted by Dan Sorensen on May 28, 2008 at 11:37 AM


@Dan,

I assume it uses the Java set of regular expressions, but I am not 100% sure.

Posted by Ben Nadel on May 28, 2008 at 11:46 AM


@Dan:

I don't think it's exactly the Java version, but I think that's probably what it's closest to. In reality it's not very likely you'll stumble upon the differences between them unless you're doing some reasonably advanced stuff anyway.

Most people stick to capture grouping (...), non-capture grouping (?:...), character classes [a-zA-Z0-9], match any character . , previous 0 or 1 times ?, previous 0 or more times *, previous 1 or more times +, and alternation (aka "or") |. These are common to every reasonably major regex system (though LUA doesn't support alternation!!)

Posted by Eric on May 28, 2008 at 11:50 AM


man, why'd you have to make it on a sunday? should have gone for monday, june 2nd so we could have had the day off work (i love 3 day weekends).

i'd be proud to wear the shakespeare regex shirt to commemorate next year's (inter)national regular expression day (which falls on a monday! w00t!) :)

Posted by charlie griefer on May 28, 2008 at 11:51 AM


I would not suggest mastering regex to the average person - it's just too much information. Yes, I've read it but I'm far from normal. :)

What I do suggest is RegEx in 10 minutes by Ben Forta (http://www.informit.com/store/product.aspx?isbn=0672325667)
It's a good book and I happen to know the tech editor intimately. He's good. :)

Posted by Michael Dinowitz on May 28, 2008 at 11:59 AM


"And, what can you wind, you ask?" o_O I can't wind anything, but I can try to win something with regular expression!

psst! Ben! blog typo. :)

Posted by Todd Rafferty on May 28, 2008 at 11:59 AM


@Michael Dinowitz: Like... how intimate? Does Judith know about this?

Posted by Todd Rafferty on May 28, 2008 at 12:02 PM


@Todd,

Good catch :)

@Michael,

The book has been added to the list. Thanks for the suggestion.

Posted by Ben Nadel on May 28, 2008 at 12:05 PM


At home I keep my copy of the Regular Expression Pocket Reference right next to my copy of Strunk & White's Elements of Style.

Both are essential references books in my life.

Posted by Jason Dean on May 28, 2008 at 12:16 PM


$madness =~ /method/

Posted by Patrick McElhaney on May 28, 2008 at 12:16 PM


I'd take the shirt. I've already got both books and I am happy with Expresso.

I wish more of my colleagues would learn RegEx--it's such a drag when I get excited about a RegEx solution and none of the other's care. . .sniff. . .they probably won't even appreciate the t-shirt.

Posted by David Droddy on May 28, 2008 at 12:33 PM


@David: I hear you! I'm looking at YOU, Brian! =)

Posted by Eric on May 28, 2008 at 12:41 PM


> post a comment below [...] on how
> much you like regular expressions

I will express my love in regex.

(?i)(me)?(?(1)\u2665((?:reg(?:ular expressions?|ex(?:p|e[ns])?)))|(?!))(?>\1\2)

@Eric, I've debugged that shirt, too. See: http://blog.stevenlevithan.com/archives/2b-or-not-2b :-)

Posted by Steven Levithan on May 28, 2008 at 1:26 PM


@Steve,

That's a bit beyond my level :) If I had to make an educated guess, are you using a conditional for Me\I and then [Heart] different spellings of regular expressions?

That ?(1) is a conditional right?

Posted by Ben Nadel on May 28, 2008 at 1:32 PM


@Ben, yes. More specifically, it's what I call a capturing-group-participation-based conditional, which is a bit of a mouthful (and is not official terminology for any particular regex flavor).

For the sake of deriving some kind of meaning, I suggest you read the regex as "If match 'me', match '[heart] regular expressions', then place 'me' and 'regular expressions' in an atomic group; otherwise end the match". It would match a string like "Me♥RegexMeRegex".

Posted by Steven Levithan on May 28, 2008 at 2:15 PM


@Steve,

Niiice :)

Posted by Ben Nadel on May 28, 2008 at 2:23 PM


I dig the regEx. I'd love to win the 2b regex shirt.

-j

Posted by Jim on May 28, 2008 at 6:35 PM


Here in Australia we actually get the 2nd of June off (as some unimportant incidental public holiday - unrelated to technical advances anyways), and since we've got this policy of moving our public holidays to the Monday any time one falls on a weekend, it's just like I get a day off in honour of I.R.E.D.

Hooray!

I was going to post for something (in an effort to obtain the sweet XKCD shirt), but honestly Steve's love for regexes in a regex beats anything I could say :-O

I will say this though:
When I first learned to use them, every problem looked like it would have a regex solution (if you have a hammer, everything looks like a nail syndrome).

The difference is (I was using perl at the time), 9/10 times it did have a regex solution. Usually a good one - a lot of my existing code shrunk from lines and lines to a single line.

Posted by Jono on May 28, 2008 at 10:48 PM


Hi!
I love RegEx very much!
This one "Mastering Regular Expressions", please ^_^

Posted by Andity on May 29, 2008 at 12:03 AM


hello... it's cool stuff...
I wanna books... about regex...
I use it a lot of time... with python...
It made me comfortable...
because I can reduce my codes...

Posted by slash sun on May 29, 2008 at 12:55 AM


"Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems."

But really. Gotta love 'em.

Posted by timdoug on May 29, 2008 at 1:43 AM


Excellent - that xkcd RegEx Shirt is pretty cool, I'd like that

Posted by James on May 29, 2008 at 3:13 AM


Thanks for starting this, Ben. I've posted my own regex contest / giveaway at http://blog.stevenlevithan.com/archives/regexday-2008 . Of course, everyone here is welcome to participate there as well.

Posted by Steven Levithan on May 29, 2008 at 5:43 AM


I love regex because I have this huge half-page long pattern to match every single TV show I watch in a couple of IRC channels I'm in. Not to mention wherever else I might be using it (i only wish word and some other text editors supported regex find..) on a daily basis. It saves me so much time I'm only too glad to celebrate a regex day.

/me loser?

Anyway, Steve's regex post owned, but I really want that xkcd shirt :( here's to hoping...

Posted by Jane on May 29, 2008 at 5:44 AM


@Jane, I haven't posted what prize I'm interested in, so I'm not in the running (intentionally).

Posted by Steven Levithan on May 29, 2008 at 6:03 AM


I don't know how anybody develops code without using the regex powers of sed and grep. That's why I'd love to have the book, Mastering Regular Expressions!

Posted by Austin on May 29, 2008 at 7:30 AM


that coffee mug is sweet, I have mastering regular expressions and the pocket reference. They are both really good. I also second taking that monday off in observance of the sunday holiday.

Posted by Shawn on May 29, 2008 at 8:56 AM


Friedls Regular Expression(2nd edition, in German) lies on my desk.
At university, as we had to write a program to query a website and print an result from the site, i used regular expression. My program was the shortest. The lecturer liked it :)
It happened me also that i said at work to a co-worker, "I can do this in regular expression, let me do it".

I would like to get the xkcd shirt.

Posted by seb on May 29, 2008 at 9:24 AM


Awesome idea! Regular expressions deserve more love than they're given.

If chosen, I'd love to win a copy of O'Reilly's Mastering Regular Expressions".

Posted by Larry Marburger on May 29, 2008 at 9:37 AM


I forgot to specify what I want.

/Shakespeare RegEx Shirt|Mastering Regular Expressions/

Posted by Patrick McElhaney on May 29, 2008 at 9:41 AM


That xkcd t-shirt is cool. :)

Input: International Regular Expression Day

/^\w+(\w)\w{4}(\s)(\w{2})(\w)\w+\s(\w{2})\w{6}(\w)\w\s(\w)(\w)\w$/\1\2\8\7\6\3\2\3\4\5!/

:)

Posted by Peter Boughton on May 29, 2008 at 9:47 AM


Jane:

>> i only wish word and some other text editors supported regex find <<

jEdit has a good search & replace with RegEx find & replace.

www.jedit.org

Posted by Peter Boughton on May 29, 2008 at 9:52 AM


Happy regex day! I'd like xkcd shirt please...

Posted by Ozan Ozbek on May 29, 2008 at 10:05 AM


Dude, I so totally love regex. I totally want the Shakespeare Regex. Totally.

Posted by Rogie King on May 29, 2008 at 10:14 AM


I'm just learning the complexities to RegEx and each day find it more useful, very cool for IRED. One O'Reilly book for learning please. Thx.

Posted by Brandon Moser on May 29, 2008 at 10:36 AM


As I am finally detoxing off of VB and entering the world of "real languages" I guess I would like: "Sams Teach Yourself Regular Expressions in 10 Minutes".

I have dabbled with them in .NET, but I know I'm not utilizing them even remotely to their potential.

Posted by Tim Goshinski on May 29, 2008 at 10:42 AM


This is very timely. I've found myself increasingly using regex lately to elegantly solve problems we're addressing in our Broadchoice Web Platform! Hardly a day goes by now without me concocting a regex to paste into a Trac ticket to show our offshore team how to perform complex matches or replacements on text, especially related to URL patterns. I always used to think regex was a bit of a hammer and that regex fans thought all problems were nails but as I've become more fluent with it, I've seen the light :)

If I win, I'd love the Shakespeare T - that's very cool!

Posted by Sean Corfield on May 29, 2008 at 11:05 AM


I've been amazed at what you can accomplish with regular expressions to shorten lots of code. I've also been amazed at how complex and cryptic the regex code can get!

One current problem I'm struggling with is how to replace delimiters around text with HTML tags in a ChordPro-formatted string using ColdFusion. e.g. parsing "A[G]mazing [G7]grace, how [C]sweet the [G]sound" looking for the square brackets and replacing them with <span class="chord"> and </span> respectively... So the final string might look like, "A<span class="chord">G</span>mazing <span class="chord">G7</span>grace, how <span class="chord">C</span>sweet the <span class="chord">G</span>sound" Any ideas? Also is there any way to get the chord out and pass it to a transpose function inside the regex?

Shakespeare T all the way!

Posted by Matt Newby on May 29, 2008 at 11:07 AM


Forgot to mention that most of the solutions for transforming ChordPro markup to HTML involves creating a two-row table for each row of ChordPro text. I'd really like to figure out how to format it using CSS instead of tables. :-) That's proving to be a little more difficult than I anticipated when I started it. Most of the open-source tools also use tables...

-matt

Posted by Matt Newby on May 29, 2008 at 11:10 AM


@Matt,

Try:

(?i)(\[[abcdefg]\d?\])

... and replace with:

<span class="chord">\1</span>

Posted by Ben Nadel on May 29, 2008 at 11:13 AM


Yes, I love regular expressions. They are pretty much the only way to process textual information containing patters easily.

And I want a cool T-shirt! Thanks.

Posted by Alexander L. Belikoff on May 29, 2008 at 12:02 PM


Regular expressions have become my life force in the last few weeks when I found out my beloved ereg in PHP is being phazed out. Far more portable and fast it makes my life that much better!

Posted by Ryan on May 29, 2008 at 12:42 PM


I'd love to own the first prize, the Shakespeare TShirt. I've always loved that different kind of art approach (I even loved the Poems in UML things ;))

Posted by tante on May 29, 2008 at 1:00 PM


RegEx: The most powerful thing that none of our programmer applicants ever seem to know much about. Sad.

I would love either one of the tshirt (1 or 2)

Posted by Mike Flynn on May 29, 2008 at 1:07 PM


Yay for RegEx Day!

Regular Expressions are a wonderful way to express your awesomeness. My favorites are the ones that do menial tasks for me, such as reformat text in my editor. I blogged it, even: (http://www.dopefly.com/techblog/entry.cfm?entry=222 and 223).

A couple years ago, I made a little util to rename files based on any regex: (http://www.dopefly.com/techblog/entry.cfm?entry=106).

Also, back in '04, I made the Viagra Expression - a big regex to counter viagra spam. You can test it online here: (http://www.dopefly.com/projects/viagratester.cfm). Always meant to circle back and improve it, but I keep forgetting.

If I win something, I think either T-shirt (L) or the O'Reilly book would be fantastic.

Posted by Nathan Strutz on May 29, 2008 at 1:09 PM


RegEx's rock. Great for validating an entire CSV line at one time baby.

^[Man created beer]

Luv the "Shakespeare RegEx Shirt"

Posted by Ryan TJ on May 29, 2008 at 1:25 PM


I like the Shakespeare shirt.

Posted by Woody on May 29, 2008 at 2:17 PM


^I am the RegEx Ninja! I love RegEx so much, I already own two of those. {2} of those? I'm not averse to owning {2,}. After all, regular expressions have [class].

Posted by Ben Doom on May 29, 2008 at 2:22 PM


Oh, and to fulfill the requirements, I want to run Hamlet in a shell. Possibly Denmark, the nutshell.

Posted by Ben Doom on May 29, 2008 at 2:23 PM


I never really appreciated regular expressions until I had to do manual string search and replacement....dear God.

Complicated stuff but powerful and worth-while. It should have a birthday that is celebrated all around the world.

Posted by Vinayak Badrinathan on May 29, 2008 at 2:35 PM


Another one: I am /(^).*($)/

Ack, that looks like a crazy Asian emoticon! Non-capturing sub-grouping is in order!

In the spirit of http://xkcd.com/208/ :
i =~ m/(^)(?:.*)($)/;

Posted by Eric on May 29, 2008 at 2:39 PM


I just wish I could master regex.

prize 4.

Posted by Vinayak Badrinathan on May 29, 2008 at 2:46 PM


@Eric, how do you read those? I'm sure I'm missing the joke.

Posted by Steven Levithan on May 29, 2008 at 2:53 PM


@Steve,

I thought maybe he was trying to say that he is "empty"? That's what I got from the non-capturing group :) But, some clarification would help :)

Posted by Ben Nadel on May 29, 2008 at 3:04 PM


i =~ m/(^)(?:.*)($)/;
is a little nonsensical. In perlish, I think it roughly translates as "I match everything." To be honest, I'm not sure what you get when you combine the binding operator (=~) with the match operator (m//).

Posted by Ben Doom on May 29, 2008 at 3:09 PM


It's probably pretty obscure. I meant it as "I am the beginning and the end" or "I am the alpha and the omega"

Posted by Eric on May 29, 2008 at 3:10 PM


@Eric,

Ahhh, gotcha. On a side note, I have always loved that phrase, "I am the alpha and the omega." I always thought it was very badass sounding.

Posted by Ben Nadel on May 29, 2008 at 3:16 PM


>> I have always loved that phrase, "I am the alpha and the omega."

Me too - ever since playing against Xan in Unreal Tournament. :)

Posted by Peter Boughton on May 29, 2008 at 3:42 PM


@Ben Doom, I'm not a Perl hacker, but I know that adding the "m" in `i =~ m/(^)(?:.*)($)/;` doesn't change anything. Some people have a preference to always use it, or not.

@Eric, the parens and the bit about some adjustments being in the spirit of xkcd/208 threw me off, but "I am the alpha and the omega" was actually my best guess at reading it the way you meant it. :-)

Since I can't help but comment even on joke regexes, I'd recommend something like this to help get the point across:

i =~ /\A.*\z/s

Posted by Steven Levithan on May 29, 2008 at 4:38 PM


@steven

I meant that you usually use =~ with the replacement operator, so that the result is bound back to the variable. IIRC (it's been a few years)

me =~ r/(ben)?\s*doom/The RegEx Ninja/ig;

Poof! The Ninja appears from nowhere!

Posted by Ben Doom on May 29, 2008 at 5:04 PM


@Ben Doom, lolz. :)

(Again, not a Perl hacker, but replacements are done with s/// [s stands for substitution].)

Posted by Steven Levithan on May 29, 2008 at 5:17 PM


@Steven

You're right, it's s///. I *always* got that wrong, now that I think about it.

Posted by Ben Doom on May 29, 2008 at 5:23 PM


All of those prizes are great so feel free to send along any of them.

Posted by Jeremy on May 30, 2008 at 12:23 AM


<Regex3

Posted by Mike Skalnik on May 30, 2008 at 1:32 AM


I wrote the history of meeting Regex at the first time in my life (on the my web page) and some SQL queries' regexes (these are all in Turkish). And also linked to this web page.

I want "Mastering Regular Expressions" by Jeffrey Friedl if I win =:-)

Posted by Can on May 30, 2008 at 10:33 AM


05/30/08 09:51:35 xkcd tshirt winner!

^.*?:[0-9]{2}\s\w\s\w\s\w$

Posted by Ben on May 30, 2008 at 11:56 AM


I love how a colleague will be complaining to me that they have to spend all day making a silly change to hundreds or thousands of files by hand, and I can swoop in and save the day with a quick perl command line. Makes me feel like a hero all the time. :)

I would love either tshirt, or the O'Reilly book.

Posted by Adam Tuttle on May 30, 2008 at 2:20 PM


Regular expressions got me through grad-school!

Posted by Zane on May 30, 2008 at 5:37 PM


Regular expressions got me through grad-school!

The xkcd shirt is cool... the O'Reilly book is pretty awesome!

Posted by Zane on May 30, 2008 at 5:38 PM


Lol...what got me through some of my projects are regex libraries :P.

On second thought, I'd really like any of those prizes. I'd love the o'reilly book or the 24 hours book but I would love to have any of those :P.

Posted by Vinayak Badrinathan on May 30, 2008 at 6:03 PM


t-shirt!

Posted by Patrick Donelan on May 31, 2008 at 5:46 AM


The first time I realized that RegEx's were f()cking awesome was when I saw RegExPal and parse URI / SplitURL's from Steve ...

I want the Shakespeare shirt ... please ... now.

Posted by Edward Beckett on May 31, 2008 at 6:13 AM


Hooray for RegEx Day!

Tip: If you're a Dreamweaver user and need to build a regular expression, start learning about the Server Behavior Builder. When you create a server behavior, Dreamweaver generates a regular expression to match the code block(s). If you're in a hurry (or especially if you're just learning regular expressions), the regexes Dreamweaver generates can be a good starting point. You'll find the regexes it generates are in your user's Configuration in .edml files (which are XML files).

Hope that helps somebody out there... :-) Happy Regex Day!

Posted by ~Angela on May 31, 2008 at 8:34 AM


// My comment is a bit larger because it has code + comments!
// I like regular expressions because the're so easy to use and let you quickly
// handle an amazing variety of pattern matching tasks with very little code.
// Written by Art Wetzel sometime in 1976 or 77 about when V7 Unix came out.
// Its not the full RegEx syntax we know today and is slower than the usual
// state-machine implementation. But... It is nice and short!
// This worked nicely as the core of my own little versions of ed and vi
// If I win I'd like the med or large xkcd RegEx Shirt!!!!

/*
* Art Wetzel's recursive regular expression matcher returns # chars matched
* the regular expression p in the target string s. The b arg points to the
* beginning of line for '^' matching (its usually a copy of the initial s)
* a return value < 0 means no match. 0 is a successful 0 len match.
*/
rem(p, s, b) char *p, *s, *b; {
int t;
char *pi;
switch(*(pi = p)) {
case 0: return(0);
case '^': return(s == b ? rem(++p, s) : -30000);
case '$': return(*s ? -30000 : 0);
case '[':
t = (*(p+1)=='^' ? (*s ? !cclass(p+2, s) : 0) : cclass(p+1, s));
while(*p++ != ']') ;
goto recurse;
case '.': t = *s; p++;
goto recurse;
case '\\': p++;
default:
t = (*p++ == *s);
recurse: if(*p == 0) return(t?1:-30000);
if(*p != '*') return(t && *s != 0 ? 1+rem(p,s+1) : -30000);
return(t ? maxf(1+rem(pi,s+1),rem(p+1,s)) : (rem(p+1,s)));
}
}

maxf(i, j) { return(i>j ? i : j); }

cclass(p, s) char *p, *s; {
int c;
for(c = *s; *p != ']'; ) {
if(*(p+1) == '-') {
if(c >= *p && c<= *(p+2))
return(1);
p += 3;
} else if(*p++ == c) return(c);
}
return(0);
}

Posted by Art Wetzel on May 31, 2008 at 6:19 PM


It good to see how many people are starting to realize how cool regexes are. I saw the light after using a regex to replace text in about 40 files in less than a minute

I wouldn't mind the XKCD T-shirt. I already have the other.

Posted by Mash on May 31, 2008 at 11:32 PM


@Angela

Any female that likes RegEx's is definitely cool by me ... { :) }

That Dreamweaver trick is a pretty cool way to learn RegEx's ...

Not to steal your thunder or anything ... but, for an easy way to "Cheat" at learning RegEx's ... By understanding the definitions of RegexBuddy's tokens, a nOOb can pick up the different syntax "flavors" of RegEx string manipulation really quick ...

Posted by Edward Beckett on May 31, 2008 at 11:50 PM


Regexes are so tremendously cool. And so are the t-shirts! I'd really love one of them. Also I would recommend Friedl's book to anyone interested in regexes. One of the best tech books I ever read. Not that I've read that many books, but okay...

Posted by Geert on Jun 1, 2008 at 3:38 AM


How cool. First there's Talk Like a Pirate Day and now this!

I have to find a way to celebrate this with my family.

Posted by William DeVaul on Jun 1, 2008 at 7:15 AM


((Happy Regex Day To )You\n)\1\2.*!\n\1

:)

Posted by Peter Boughton on Jun 1, 2008 at 8:42 AM


To celebrate today's holiday, I've compiled 5 Tips for Working With Regular Expressions. (Tip #1 is the tip I left in the comments here, so you can skip that one...) As not to take up a lot of room here on Ben's blog I've posted the tips on my blog instead.

To see all 5 tips, visit http://www.dwmommy.com/?day=6/1/2008#blog627 or click on my name for this comment.

I hope the tips help and that everyone has a wonderful National Regular Expression Day!

Posted by ~Angela on Jun 1, 2008 at 9:17 AM


@Edward - Thanks, one of these days I'll have to look at RegexBuddy (too bad it isn't on the Mac though, prefer not to switch back and forth to the Windows side)

@Ben - Thanks for hosting, umm creating.... no, inventing -- oh you know what I mean. :-) I see your comments are using a regex to make links out of URLs provided in the comments. Great use for a regular expression there.

@Everyone... Anyone know some good tools for RegExes on the Mac?

Posted by ~Angela on Jun 1, 2008 at 9:23 AM


@All,

HAPPY REGULAR EXPRESSION DAY!

I really appreciate everyone that came out participated. I am glad to see that so many people are finding regular expressions as awesome and wonderful as I do. I wish I had had more time to make this first day better, but I am sure the participation we have seen so far is only a sign of bigger and better things to come next year.

Thanks to everyone. Will be selecting winners tomorrow. Until, then, enjoy!

Posted by Ben Nadel on Jun 1, 2008 at 5:12 PM


:) I think i am too late, but I would like to say that this is Ben's cool effort.

Posted by M.khalid on Jun 2, 2008 at 9:27 AM


Congratulations to the National Regular Expression winners below who have been selected at random:

* Sean Corfield
* Andity
* Ryan TJ
* Austin
* Jono

Thank you all for having fun with this and helping to get the first annual Regular Expression Day off the ground! I was really excited to see people expressing a love for the language and really sharing some of the ways it has made their lives easier. I am hope that next year is even more exciting.

I will send each of the winner a follow email to gather the necessary information.

Thanks again everyone!

Posted by Ben Nadel on Jun 2, 2008 at 8:36 PM


I'm a big fan of API's that auto-correct for common mistakes. For example, if the API says something like Fusebox or ColdBox about including views, i.e "don't include the .cfm extension", which I've done in a number of places, I would write the code so that if they make a mistake and include it anyway, the API will correct the mistake. So frequently in my code you'll see something like this as a quick method of auto-correcting:

rereplacenocase(path,"(\.cfm)?$",".cfm")

remove it if present, then tack it back on. :P

A lot of my regex work ends up being really small pieces like that, rather than big hairy complicated regexes for things like html scrubbing (which I do with XSLT now).

Posted by ike on Jun 12, 2008 at 2:48 PM


Post Comment  |  Ask Ben


Home   |   Web Log   |   ColdFusion   |   Projects   |   Resume   |   Job Form   |   Search   |   Contact
Epicenter Consulting - Custom Software Solutions for Business Evolution HostMySite.com - The Leader In ColdFusion Hosting