Skip to main content
Ben Nadel at CFCamp 2023 (Freising, Germany) with: Michael Wiesmeyr and Cynthia Ramos and Raphael Mürwald and Marcel Mayr and Joseph Pernerstorfer and Daniel Pötscher and Andreas Breit and Luccas Hansch and Roman Schick and Christian Immitzer
Ben Nadel at CFCamp 2023 (Freising, Germany) with: Michael Wiesmeyr Cynthia Ramos Raphael Mürwald Marcel Mayr Joseph Pernerstorfer Daniel Pötscher Andreas Breit Luccas Hansch Roman Schick Christian Immitzer

The 4th Annual Regular Expression Day (And Prizes) - June 1st, 2011

By on

Can you believe that it's almost time for the 4th annual Regular Expression Day?! That means another chance to celebrate the super powerful and infinitely awesome string parsing and manipulation functionality provided by the Regular Expression. This pattern matching syntax spans all modern programming languages and improves the lives of all developers, regardless of language or platform. They truly unite us as "problem solvers," arming us in the war against data mining, manipulation, and validation.

NOTE: If you are already completely lost and have no idea what I'm talking about, please checkout my video and slide presentation - Regular Expressions, Extraordinary Power. They will blow your mind and change your world forever.

This year, the prizes are pretty exciting! The wonderful folks at O'Reilly Media have offered to give away a lot of eBooks (ePub, Mobi, PDF). I don't want to say just how many; but depending on how many people participate, we might have enough books to give one copy to everyone!

In today's world, if you are reading this blog post, you already have a device that is capable of displaying eBooks (like the ones O'Reilly is sponsoring); but, not everyone has an awesome device for reading eBooks. As such, I want to make sure that one grand-prize winner will be able to walk away from this Regular Expression Day celebration with a brand-spanking-new Apple iPad 2 (courtesy of BenNadel.com). This device will give you access to iBooks - the application that let me finally fall in love with the electronic book experience.

In the past, I've kept participation in the Regular Expression Day activities pretty low-touch; but, since we have such a big grand prize this year, things need to get a little bit more involved (and hopefully fun!). In order to participate, I'm asking that you upload a photo of yourself celebrating Regular Expressions in some way (using the form below). I don't care if it's just wearing a RegEx tee shirt, holding up a RegEx book, writing down your favorite pattern, or whatever - just show a little love and you'll be entered to win!

I took the liberty of kicking off the first photo. This day is suppose to be joyous. So, please join me in just having a great time and reveling in the awesomey goodness of the Regular Expression!

Reader Comments

15,640 Comments

@Peter,

Ah, yeah, it totally should. Thanks for reminding me. I was up really late one day putting this together and forgot to link it. I'll fix that up in the AM.

3 Comments

The kids were just happy they got cake! The levels of weirdness in this house are reaching all new levels...

15,640 Comments

@Cate,

"levels of weirdness in this house are reaching all new levels..."

... yeah, I call that an "appropriate" level :D

383 Comments

I don't really know Regular Expressions that well, so I tried to be really original with the image, and I also did a lot of research in an attempt to compensate. :-)

383 Comments

I wanted to use the colors, because I am highly fascinated by the hexadecimal value system. :-) I did work to try to make all of the food colors that would be colors of something edible and within the proper ranges. If you can't tell, the main course is a "hamburger" written in hexadecimal. I did some research and looked up all of the possible combinations of the color brown in hexidecimal that a hamburger that was edible could possibly be. I included mustard, tomatoes, lettuce, and buns, and for each of those, I tried to keep it within the range that would be a color of something that would be edible. For desert, I did blueberries. :-)

383 Comments

And I'm sorry if that was explaining something that was self-explanatory. I didn't mean to insult anybody by explaining that. Please disregard if you already knew what it was, I was just explaining for those who might be curious and not exactly get it.

57 Comments

I'll complain! You chopped the top of your head off. :P

Ben - not sure if comment notification is working?
I subscribed with my earlier comment, but didn't receive any notifications for these messages. Checked my spam folder (though I have a filter to stop the messages going there), and sent myself an email to the same address to check my end is working (seems to be).

15,640 Comments

@Matt,

I would definitely accept stuff until end of day tomorrow (1st) - you should totally rock something out! :D

@Anna,

I love your enthusiasm. And, as far as explaining Regular Expressions, please don't feel bad. Regular expressions are notoriously hard to read. It's like humming - in *your* head, you're humming the perfect tune to a song; but to everyone else, it just sounds like a buzzzzzzzz :) The power of regular expressions are colored by their terseness and density - explanation is always welcome.

@Peter,

I cut off your head?!? Sorry - the images get resized automatically using CFImage - if there were any shenanigans, they were unintentional. Feel free to re-send it to me directly and I can fix the problem (ben-at-bennadel.com).

My email can be a little weird. Sometimes I get bounce-backs that say I have a problem with my email headers. That's one of the things I have not gotten worked out just yet.

15,640 Comments

@Peter,

I just got a few bounce-backs just now. I get the following detail:

"Remote host said: 550 Access denied - Invalid HELO name"

... maybe it's time that I actually figure this out (I've known about this problem for like 2 years, literally).

57 Comments

Ben, no my head is fine; I was teasing Anna after you said no-one would complain - so I was complaining that she'd cropped the top of her own head off. :P

Anyway, I checked on that error message and it seems likely to be related to a setting on the mail server which is enabled "Require incoming SMTP connections to send HELO conforming to internet standards (RFC2821 4.1.1.1)".

Will try disabling that setting and seeing if that lets the mail through...

57 Comments

Yep, that worked - got the copy of the comment within about 5-10 seconds.

So that suggests your mail software is sending a HELO but what it is sending doesn't conform to RFC 2821 (i.e. the SMTP protocol).

As for how to fix that... I've no idea, the RFC does go into detail on what's required:
http://tools.ietf.org/html/rfc2821#section-4.1.1.1
...but I suspect it's more likely to be a configuration-level issue.

383 Comments

@Peter & @Ben:

I had noticed the email thing, but I thought it was my email address or my email had something to do with it, because I have a friend who posts here and gets emails when someone comments.

@Peter: I didn't intentionally cut off the head...that's the way the picture came. And how do you know its me? It could be a stock photo I got off of somewhere like iStockPhoto.com for you guys to enjoy. :-P

31 Comments

@Ben-

I've had a couple of ideas in the back of my head ever since I missed RegEx Day *last* year. I'll see if I can get an image put together sometime tonight.

15,640 Comments

@All,

Happy Regular Expression Day 2011!!!! Woohoooo!! :D

@Peter,

Yeah, I think it's something I have to set in my SmarterMail setup (I dislike SmarterMail). I sent myself an email last night to fix it today... we'll see if that happens.

@Anna,

Oooh, very mysterious :)

@Matt,

Ok cool - good luck my friend.

12 Comments

Happy RegEx Day 2011! :)

Once again, awesome work Mr N. My strings would never be splitting as beautifully as they are now were it not for you.

14 Comments

While my favorite expression is very simple, it is something that I use all the time.

find (.*)
replace \1 ,

//forgot * in first picture, resubmitted

383 Comments

@Ben: I just read the requirements that you upload "a photo of yourself celebrating Regular Expressions in some way ", therefore, I guess it has to be me, so if I MUST prove my identity if I were to win one of the fabulous prizes, then I suppose I could make a trip up to NY and collect in person...maybe a road trip to New York is long overdue. :-)

Alternatively, I could also send you a package via mail to prove my identity containing the following items:

1. The costume pictured here. 2. A collection of photos in said costume. 3. The originals on CD form of all of the pictures. 4. A shirt for you to give away to a close personal female friend to whom the shirt relates (or you could keep it, but since it is female-centric, then you would probably feel a bit too feminine or weird wearing the thing). The shirt would prove it is me, because it is currently being sold on both of my 2 sites. :-) And, of course, I would have to get to you in some way the urls to said sites for another means of proving my identity (I could probably arrange this through email).

Have I ruined the mystery so far? :-P

(I am famous for that)

I could ALSO send to you in email my other entry I did first, but I put it to the side in favor of this other one I submitted. One of the reasons I chose the one that I did is because I did the first one almost solely and completely...well, probably just completely, probably no almost to it...in paint. Microsoft paint...the free program that comes with almost all of your computers, since I did not have Adobe Photoshop on any computers that I could open at my disposal.

@Lola: I am glad you enjoyed the explanation. I did, however, when I was looking at the menu I had created for the project, notice that I made a small error...I forgot the "f" in the number 1 part of the menu. To @Ben: Do I need to fix that and re-send it? Or should I just submit my other entry? Thanks!

57 Comments

Anna wrote:
> And how do you know its me? It could be a stock photo ...

Because I'm a photographer and I tend to recognise the characteristic look that stock photos have. :P

(I was also tempted to drop a remark about sitting outside your window, but after my last joke I'm rather wary that could go the wrong way!)

Anyway, as a quick aside, for those computers you have without Photoshop on, you could consider Paint.NET which is freeware and pretty easy to use, but more advanced than Microsoft Paint.

383 Comments

@Peter: Thanks for the tip! I'll add that to my database bank of information that may help in the future! :-) And this time around, I'm afraid it might not have done any good even if I had known, because I was working on a computer that I wasn't really allowed to put any extra software on, and I only had paint at my disposal at that particular time. (the reason I messed the 2nd one up is because I did it while I had a lot of distractions in the room, but I did have photoshop, so was able to do a little bit more in the way of Regular Expressions). The computer I can't put any software on...it even complains when I try to access im each time. I have installed an im program on it, but will have to take it off when I am no longer using this computer or in possession of it. I was accessing im through the web, but every time I did, it complained. Plus, I get blocked if I go to any site like facebook, myspace, twitter, or any social networking site. Well, actually, I think I can when I am not on the network, but I am usually on the network on this computer. I know there's a program GIMP (I think it is) on the web that you can use, but again, I'm not really supposed to install any more programs on this computer (with the im, I am able to get by telling them I have a lot of developers outside of work I talk to about work-related problems, and that is actually the truth). I guess it's all for the better, anyway, that I was able to do the picture on the other, because it allowed me more freedom of expression, including the picture I chose and the Reg Ex I was able to put on there.

I'm afraid if you sat outside my window, you would probably be very disappointed to see me without any makeup/costumery, in regular clothes and with my glasses on, since I do not sit around in that stuff on a normal day-to-day basis, and I usually wear all of those other things and not the make up...I almost never wear it if I am not getting pictures taken. You might be the one who would be scared. haha. This particular series of pictures came from a set where I was portraying a character...I was in a play/production, so there was a certain look I was having to capture. I chose it for it's story-telling and 'editorial' value...it's the kind of picture you can add words to and it kind of makes sense that it is actually telling a story. But it's really not what I usually look like day-to-day.

10 Comments

Where would we be without the humble regex? A well-crafted regex is a thing of beauty! Viva la RegEx!!!

Or is it "el RegEx"?

I have no idea; I was a Russian major in college.

31 Comments

By the way, how appropriate is this- I've been rocking the regular expressions all day. Using C# (Yeah, I know- it's a M$ platform), LINQ, and RegEx to launch processes with certain behaviors based on masks that match files coming in to an FTP server.

383 Comments

That's cool, @Matt! I guess all you have to do is copy some of your Reg Ex's you have been doing for work and paste it over top of a picture that has you in it, and you're good to go for your submission! :-)

57 Comments

Anna:
Yeah, pointlessly locked down computers are very annoying!
Fortunately they weren't stupid about it at the last place I worked, and generally trusted the developers not to screw them up; I think social website blocking was the worst we had.

GIMP is ...well, it's popular amongst Linux users, and has plenty of features (quite a bit more than Paint.NET has), but personally I find it *really* irritating whenever I have to use it, so it's not something I recommend.

There's nothing wrong with regular clothes and glasses, but I am slightly disappointed that it was a costume for a play and you didn't dress up especially for regex day. :P

Jason:
I think it'd just be "Viva RegEx", since la/le/el translate to "the" and regex isn't a single thing. (But I didn't do *any* languages at college, and I did German before then (which I can barely remember), so I could be completely wrong.)

31 Comments

@Anna:
Yeah, I probably could, but this is more functional than fun. I've got an idea in mind- I just need to find time to fire up GIMP, overlay a RegEx over the image I've got picked out, and upload. Going more for "funny" than "complex".

Although 2 weeks before a major release, I'm mostly going for "All work and no play makes Matt something, something..."

383 Comments

@Matt,

yeah, that'd be cool, though, functional and funny. If you could put something functional and elaborate over a picture and have it make sense, that would be something. :-) I had to go with what I knew and was able to put to a picture...and, of course, with a little bit of research, as well.

I know what you mean about all work and no play and deadlines, releases coming up, etc. I have a deadline this coming Monday, and our requirements discussion meeting has been set for Friday, so I am really hoping they will move the deadline date forward. Otherwise, it'll be work all weekend for me...not a fun weekend!

@Peter, I am just glad that they don't block Bennadel.com. :-) I don't mind myspace being blocked, other than I use it to play w/ css. I don't really mind twitter being blocked, either, other than I have some developer friends on twitter who sometimes post about groovy code and things they are doing in the development world that it might be nice to know. I would rather facebook not be blocked. I have developer friends on facebook, and it is probably the site of social networking that I actually use the most. So it's the one, probably, that I miss the most when it is blocked at work. (I will interject that I can get it on my phone, though, so I can do that while at work, but it still is not efficient or necessarily conducive for my work environment for me to be on facebook on my phone while at work).

Yes, it was a costume for a play, so it kind of was my own personal stock photo collection. :-)

w/ the GIMP and Paint.net thing...they used to have this program where you could manipulate files online, so it wasn't a problem if you could access that site in terms of not being able to put any extra software on your computer. I think it was called animation station.com. I'm almost certain it is not up anymore, and I am not aware of any other online type of program like that.

@Peter & @Jason:

If it is french, I think it is Vive, like Vive la France. I believe I have seen that somewhere before. As to whether you used the la/le thing, it would depend on whether RegEx would be male or female, and I would guess by looking at it that it was male, so it would be Vive le RegEx if you weren't concerned about the plural thing. If it were plural, and you were doing it that way, it would be Vive les RegEx, because you use les before plural words...and I think that is regardless of whether they are male or female.

Although I think you guys were trying to speak spanish, and I have NO idea about that. I just know the french.

57 Comments

Yeah, viva is Spanish and Italian, whilst vive is French.

I assumed Jason was going for Spanish because of the "el", which isn't Italian or French, but unfortunately knowing that doesn't help with knowing what the appropriate way to phrase it is.

As for whether regex is masculine or feminine... well, a regex is a bunch of complicated but beautiful lines and curves, which can easily be misunderstood. Uh, no comment! ;)

15,640 Comments

@Anna,

You are too funny :)

@Jason,

"Where would we be without the humble regex?"

.... in a bad place :) Viva la RegEx indeed!

@Matt,

Sounds awesome! What in LINQ? I've heard of it before, but am not sure what it is. Is it like an object-query language or something. I thought I heard someone refer to it as "XPath for objects," but I could very well be thinking of something else.

@Peter,

Ha ha, this is priceless:

"regex is a bunch of complicated but beautiful lines and curves"

This just makes me smile.

31 Comments

@Ben:

LINQ is a .Net technology that lets you join and query object using an SQL-like syntax. So, for instance, I could do the following:

List<string> fileNames =
(
from rule in db.FileRules //A database table
join file in new DirectoryInfo("some path").GetFiles("*.txt")
on rule.FileName equals file.Name //The join
select file.FullName
).ToList()

db would be a LINQ To SQL database connection, FileRules is a table that has a field named "FileName". DirectoryInfo.GetFiles() returns a collection of FileInfo objects, of which Name and FullName are two properties.

The net result is that I'm joining a file listing read straight from the disk to a recordset queried from the database to get a list of files that match some set of rules in the database. Fairly similar to what I'm working on now, actually.

383 Comments

Thanks, @Ben, sometimes I actually try to sound funny. I'm afraid sometimes that some people don't really get my sense of humor, though.

Gosh, @Matt, that sounds really interesting! (not trying to sound funny here). Seriously. I have tried my hand at .net stuff before, but I was never able to get it. I guess getting it in the right environment could possibly happen, but it just hasn't happened yet! I am now working in php and coldFusion. I noticed a couple of job announcements on the job board with them looking for that skill set, so it makes me feel good I am expanding my skill set to an area that is considered useful. :-) If I should ever need to find a job...I really like the one I am at now!

Although with our spelling of Regular Expressions, it does look very masculine, the way it is spelled above in a different language, it is more feminine. I didn't think about that, but I guess it does take on a different spelling in a different language. :-/ I was referring to the SPELLING of Regular Expressions looking masculine, but I guess this -> {}()(.)(.)(_!_)? does look pretty feminine with all of the curves and all, but what about this -> []. That looks pretty masculine. And also || <- I think it looks masculine myself, but I know a lot of you guys like your women to look like that -> || (except that's too fat for you. :-P)

15,640 Comments

@Lola,

That is totally true! Sometimes, I go out of mind trying to figure out why something is matching as "expected."

@Florencia,

No worries, there's always next year :D

@Matt,

Dangy! That's some pretty cool stuff. That must require some interesting layers of abstraction behind the scenes to make all these things inter-operable.

@Anna,

This is what happens when I try to draw women - I err on the curvy side :P

www.bennadel.com/blog/1872-Using-Base64-Canvas-Data-In-jQuery-To-Create-ColdFusion-Images.htm

15,640 Comments

@All,

I just wanted to say THANK YOU to everyone who participated! You guys are the cat's pajamas. I have sent your emails off to O'Reilly Media who have generously sponsored the books. They originally offered 25 books and we had 27 people participate, so we'll see what happens.

NOW, I have to figure how to select the iPad winner .... drum roll....

4 Comments

I'm praying...!!! my home was burglarized on Christmas 2010 and I lost all my computers and music equipment and now live on a couch at a relatives!

I'd be fine with some kind of random thing, like a roulette wheel... cmon Kharma give it backwards!!!!!!!!!!!!!!!!!

383 Comments

@Ben, That is great! Ghetto-booty-fabulous. :-) Believe it or not, I have a best friend who has almost that exact same proportion. I think the waist is smaller, creating a greater outward curve, but I think you get the picture. :-)

You can take your time on selecting the winner, at least that is fine by me. I didn't win the lottery, so. :-( boo-hoo. (somebody did, though)

15,640 Comments

@Alexander,

Oh man, I'm sorry to hear about your situation! That sucks :(

@Anna,

Ha ha, "Ghetto-booty-fabulous" :P

@Jason,

There you go - sometimes you just have to get it out of your system.

15,640 Comments

@Jason,

Oooh, I thought you were making a RegEx :D Yeah, sorry, this site was built before I knew anything about UTF-8 and i18n.

15,640 Comments

@WebManWalking,

I also enjoyed that one! Though, I have to admit, it took me like 10 minutes to work it out. I kept using "B" as the first group. For some reason, my mind was completely blanking on the fact that patterns don't have to match at the start of the string.

383 Comments

@Ben & @Webmanwalking & @all, really...I didn't understand that one at all, actually. I have already admitted to my limited knowledge of RegEx, and my need to try to be creative with the picture because of it. The one you are referring to...I thought that thing in the middle was an emoticon thingy for boobs! (sorry if I was wrong). thought it was some sort of joke or something.

290 Comments

@Ben,

I don't see a charset declaration in the View Source. If you're generating these pages with ColdFusion, you ought to be able to set the charset to UTF-8. Ever since CF became Java, the default output charset has been UTF-8.

It's possible that the Russion will look right once the browser realizes that it's looking at UTF-8. (That's asumming that it actually is CF-generated UTF-8, of course.)

290 Comments

@Anna,

Copy and paste #REReplace('Barney Boisvert', '(.).(.)(.)y(.).*', '\3n\4\u\2\1d\3l')# into a CF page and cfoutput it. You may be surprised at what you see.

383 Comments

still have no clue how it happened, though. lol. I thought that middle line was a joke that meant "Barney Boisvert loves boobs" lol

15,640 Comments

@WebManWalking,

Yeah, my problem is, I am not sure what character encoding I have in my database. Since this site is so old, it's possible that I have some junky charset encoding. If I put a UTF-8 encoding on the page, it might mess more things up.

... clearly this is what happens when you duct-tape a site together, piece by piece :D I'll check the database and make appropriate meta-tag updates if necessary.

"pair on the right has more cleavage."

... ha ha ha.

290 Comments

@Ben,

You're right.

In order for it to be worth the conversion effort, you have to have specified acceptcharset="UTF-8" (IE 5+) and accept-charset="UTF-8" (all others) on the form tag. Gotta start off knowing what you're dealing with. Who knows what you have on your database.

Not worth it, not for existing pages anyway.

383 Comments

@webmanwalking,

haha, the pair on the right having more cleavage. Is this one person with 2 pairs of boobs? lol. kind of like the uni-boob in Kung-choo pow enter the fist (I am sure I misspelled something in there, but don't know what it is), except this has 2 sets. Or a set in the middle and then a uni-boob on either side on the outside. That's kind of what I thought it was because of the . and the y. I thought those separated the one set in the middle from the uniboob on either side. lol. (or it could be that the ones in the middle represent the boobs in the front, and the . and the y separate the other two on the outside, which represents the back boobs that this person has)

@Ben,

If I must stay on topic here, :-P, duct-taping them together does create more cleavage. :-D But, it does squoosh (sp?) them together so that it's like the twins are kissing each other or something.

383 Comments

@Jason,

I mentioned duct-tape in order to stay on topic, as it had been mentioned previously, but for that particular usage of it, I have never actually used duct tape myself, so I wasn't thinking of the ripping off part...I have, however, used athletic tape, and for the record, if anyone is wondering, it works better. Plus, the removal is easier, so it doesn't hurt as much (I am guessing...again, I have never used duct tape for that purpose) But, also for the record, neither duct tape nor athletic tape are used in either of the 2 photos submitted for the reg-ex project. :-P ahhhhhhh...what women do for beauty. The price of beauty!!! Sigh...

6 Comments

Neither duct tape nor athletic tape were used in the creation of my photo either! But damn, I wish I'd thought of that before I bought a certain someone an expensive stick-on undergarment for use with her prom dress!

Ben, I just never know what I'm going to learn about on your site.

15,640 Comments

WINNER WINNER CHICKEN DINNER :D

Ok, so I'd like to say that I came up with some clever way of selecting the winner... but I didn't. I couldn't think of anything creative so I just ended up using ColdFusion's RandRange() to select the winner.......

And pseudo-random-number generation has determined the winner of the Apple iPad 2 to be:

Bradley Moore!

Congratulations my friend!

And thank you everyone for participating. You've all helped to make the 4th Annual Regular Expression Day a lot of fun and a big success!

Also, a quick reminder that O'Reilly Media should be getting in touch with you regarding the Regular Expression Cookbook.

Bradley, I'll shoot you a DM on twitter to touch-base.

290 Comments

@Anna,

I think the dot between the pair on the left is just a freckle.

If you're looking for odd-numbered evaluations of boob instantiations, you shouldn't limit yourself to Kung Pow: Enter the Fist. It's very silly, but so are parts of Total Recall and Good Luck Chuck. You may need to see the DVD/Blu-ray versions of the latter 2 movies to know why I mentioned them. (Certain parts might not make the ABC Family Channel edit.)

14 Comments

Thanks for the fun and the interesting conversations.

Had a bit of fun yesterday too.

Bradley Moore
find: (B)(radl)(e)(y) (Mo)o(re)
replace: \1\3 \2\3\4 \5\6

383 Comments

()()().
()()()

That's for the women, since there are already enough boobs on here for all the men. Well, that is my attempt at putting something up in regular expressions to symbolize men for the women. :-) But I don't know if it is going to go through well. See? Regular Expressions can look very masculine, too. :-) (I even put a belly button on it below the abs, but it's a little sideways. :-/

@Webmanwalking,

I have Good Luck Chuck, I'll have to watch it, and I will have to try to get Total Recall...

290 Comments

@Anna,

In Good Luck Chuck, I believe that the (literal) oddness is in the extras... deleted scenes or somewhere like that. It's been a while, so I forget exactly where.

15,640 Comments

@Anna,

Whoa whoa whoa... you've never seen Total Recall?!? It's probably one of the best movies ever made. You now know what you must do this weekend!

383 Comments

@Ben,

Ok, I guess I will have to do that this weekend. :-) Which is good since this weekend will be hot, hot, hot here! You are now lucky to be in New York with the cooler weather than here with it being SO HOT!!! I don't think I have seen it, but then again, I may have, but it would've just been awhile ago. I'll have to watch it, though. :-)

@Webmanwalking, I will have to check that out, thanks!

383 Comments

Thank you! Is it an action flick? For some reason, it sounds really familiar, and I think I may have seen it, actually, a long time ago, but I might as well watch it again if I can't remember it. I had finishing Son of the Mask in my lineup next, but I could definitely find the time to watch Total Recall, I am sure.

15,640 Comments

@Anna,

It's action, it's adventure, it's romance, it's sexy, it's science, it's sci-fo, it's political.... oh, and did I mention it's SCHWARZENEGGER!!!

383 Comments

Finally finished watching Total Recall...thanks for suggesting it! I started it over the weekend, but had to wait until last night to finish it, because I had a huge deadline on a project I just got the info for on Friday, and so I was really in a bind trying to meet this deadline, but the work on it is going well enough to where I was able to finish the movie (finally) last night. Thanks for the suggestion...I did enjoy the 3-boob-weirdness of it (sorry if I just totally ruined the plot for anyone who hasn't watched it). I guess you could combine that 3-boob weirdness with the 1-uni-boob weirdness of Kung Choo Pow Enter The Fist and get the RegEx up above (.)&(.)(.)(.) = Kung Choo Pow Enter The Fist & Total Recall. :-D

Schwarzenegger is cool, and I like Action flicks, it is my favorite genre. One of my favorite movies of all time, which is from the Action genre of course, is Maximum Risk. If you HATE Van Damme, then you may still enjoy it, because it is the only Van Damme movie I have ever watched to completion, and I still loved it. I am not sure if I would like his other movies, because I haven't watched any of them (I don't think), to completion, but I really, really, thoroughly enjoyed this one. It is also a love story, somewhat, if a messed-up love story...but it is awesome (in my opinion). One of my favorite things about it, besides the fact that it has martial arts in it, which is a plus, is the fact that part of it takes place in france, and I happen to be a francophile. I take that back about not having watched any other van damme movies to completion...I saw Blood Sport, and I believe it is a Van Damme movie also, and loved it as well. But anyway, watch Maximum Risk (if you haven't already)...it is awesome.

(about Maximum Risk...another thing I liked about it is that it had somewhat of a comedy element to it, even though it wasn't a comedy per se. And it was a different type of commedy...I would probably call it a dry comedy...not a dark comedy, but a dry one, but I enjoyed it)

15,640 Comments

@Anna,

Glad you liked it! It's such a quality movie!

As far as Van Damme is concerned, I don't think it gets any better than Time Cop. The classics (Blood Sport, Kick Boxer) were great when I was younger; but I don't think they stand up to the test of time ... though, they do have good fighting. Time Cop, however, has enough of a story to really keep it entertaining.

Although, now that I think of it, Lionheart may be a better mixture of overall fighting and storyline.

I keep thinking one of these days I have to have a Van Damme marathon on Netlflix :P Just to see how far I can actually make it.

383 Comments

@Ben,

I love action movies, and I love especially martial arts action movies. That said, I can't say that I necessarily love all martial arts movies or even all action movies. I really like the movie to have a good story too, or at least somewhat of one. I'll admit that Bloodsport was a good martial arts movie, but that it was also probably a little short on the story side. I will have to see Time Cop and Lionheart, because I don't actually have anything against Van Damme, I just simply haven't seen any of his movies besides Blood Sport and Maximum Risk. You have to see Maximum Risk if you haven't already, because it is awesome! It is probably still one of my favorites. I think I already mentioned, but it is a great action flick, with a little romance thrown in, and also a little of the dry comedy. (it's so great of an action movie, that it starts out with an action scene. But I won't say any more than that, so as not to spoil the story any more than I already have).

Action is my favorite genre, and I also like horror, but Romance and Drama comes up as a close second. The thing about Romance and Drama is that I don't like all romance or all drama, but I pretty much like all action. Romance and Drama depends, of course, more on the acting ability of the actors/actresses. I think with action, the actual acting ability can be a little lacking and it can still be a good movie. IMO.

Comedy is probably my least favorite genre. The reason is because there are so many different types of comedy, and I don't necessarily like all of the types of comedy. There is some comedy that I don't get, and some that I think is just plain stupid. I get it, I just think it is stupid and not funny. And yes, I do have a weird sense of humor, and I am sure that holds me back on liking a lot of comedy. I do love slapstick comedy, just clean good funny stuff, but I don't necessarily always like what people refer to as "dark" comedy, and toilet humor isn't necessarily always my thing either.

@Alexander,

I'll have to check that out, thanks! It sounds really good!

383 Comments

I have a question about RegEx (imagine that!). RegEx can be used, can't it, like in regEx replacement, to search for several different things and replace them with other things depending on what is found and what needs to be replaced. I should probably give an example to illustrate my question. Say, for example, you have a column of values, and then you have a column of values that you want to display which are a bit different. Let's say the values you have are:

lace, silk, velvet, velour, leather

and you want to replace them with

lc, slk, vlvt, vlr, lthr

respectively. For instance, you do NOT want to replace lace with slk if it is found, nor do you want to replace lace with all of lc, slk, vlvt, vlr, lthr; you only want to replace lace with lc and so on, if those values are found. It is possible to do that using RegEx, isn't it? I guess I am going to have to go dig into my new Reg Ex book from Reg Ex Day to figure it out, huh? :-)

57 Comments

Anna, the answer is "yes and no" :P

The answer I suspect you *don't* want is:

Yes, like this...
<cfset ShortVersions = ReReplace(LongVersions,'[aeoui]','','all') />

Whilst that fulfils your brief, I don't think it's what you're asking.

Similarly, doing this:

<cfset ShortVersions = ReReplace
( LongVersions
, '\b(?=lace|silk|velvet|velour|leather)([lsv])[aie]a?([clt][vhk]?)(?:e|ou)?([tr]?)\b'
, '\1\2\3'
, 'all'
) />

Also solves the problem, and shouldn't match too much (like the previous one would).

But is that what you want? (Almost certainly not; it'd be horrible to maintain!)

The simplest solution is probably to just do this:

<cfset ShortVersions = LongVersions
.replaceAll('\blace\b','lc')
.replaceAll('\bsilk\b','slk')
.replaceAll('\bvelvet\b,'vlvt')
.replaceAll('\bvelour\b','vlr')
.replaceAll('\bleather\b','lthr')
/>

But whilst a lot better than the rest, it's not necessarily the most maintainable solution.

What would be better, but that you can not do just yet is perhaps this:

<cfset ShortVersions = ReReplace
( LongVersions
, '\b(?:#listMaterialNames()#)\b'
, convertMaterialName
, 'all'
) />

<cffunction name="listMaterialNames" returntype="string">
<cfreturn "lace|silk|velvet|velour|leather" />
</cffunction>

<cffunction name="convertMaterialName" returntype="string">
<cfargument name="MatchText" />
<!--- translate Arguments.MatchText into short version. --->
<cfreturn ShortVersion />
</cffunction>

Which calls a function for every match, and that function call could use any CFML logic to lookup what the short version could be, including a database call (similarly, the list function could be a database call and use ValueList)

Unfortunately, the ReReplace core function doesn't support this, so you can't actually do it with currently built-in functions.

Ben has written a blog entry (years ago now) on how to create your own replace function that *can* do it, but unfortunately I can't find that blog entry - it's not too tricky though.

Anyway, I hope all this is actually in some way helpful/understandable, and hasn't completely confused things? :S

383 Comments

Awesome, @Peter, AWESOME!!!! And actually, I am currently looking at doing it using oracle's Regular Expression Replace function. I know, I know...this does seem to be a little beyond my level expertise, huh? But I'm certainly not opposed to using ColdFusion to do it, I just thought I would challenge myself and stretch my boundaries a little bit and try something new. I was guessing that regardless, even if I tried to use the RegExReplace in oracle, that the RegEx would actually be the same, so it still makes your reply very useful. Thank you. :-) I figured @Ben had written a blog entry, and on just about any other day, I probably would have had the time to dig it up and find it, but I am up against a deadline right now with this, so I just don't have the time right now. Which means I may have to do it the cf way if I can't get the oracle one to working right, but that would't be so bad, would it? :-)

btw...I kind of figured the WAS a way to do it if there was a way to turn those boobs up there into @Ben. :-D

57 Comments

Doh, I forgot the code blocks. :(

Anyway... as for which of the three books to choose, I'm also undecided.

I've got the 1st edition of Mastering Regular Expressions, and it's good, but the 3rd edition has even more (particularly on java.util.regex, which didn't even exist at the time of the 1st edition, and is what I use most).

But from Ben's review of Regular Expressions Cookbook the other day, that also sounds like it could be just as useful in that respect.

I keep meaning to go see if there is a preview and/or table of contents available so I can get some idea as to which I'd prefer, or someone who has read both and is able to compare them, but not done had time to do either of those yet.

(Not too bothered about the pocket reference myself, since I assume that's exactly what it is, and doesn't go into detail on the internal stuff like the other two do.)

57 Comments

Heh, I haven't even got a clue what sort of regex Oracle does.

If it's a one-off task, then using CF is probably simpler for now.

If it's an ongoing thing, Oracle might be better performance (since it's doing everything on the same server rather than passing back and forth).

383 Comments

@Peter:

Thank you very much for your response. I have to say, after having studied them all in detail, I really love this one:

<cfset ShortVersions = ReReplace
( LongVersions
, '\b(?=lace|silk|velvet|velour|leather)([lsv])[aie]a?([clt][vhk]?)(?:e|ou)?([tr]?)\b'
, '\1\2\3'
, 'all'
) />

beautiful!

May need a little help decifering, though. What it basically is doing is, it is taking the things it is seraching for, and then it is saying "keep the l, the s, and the v's, starting out the words in the search string. Then, it is eliminating the a the i and the e adn the a also (or making them optional). Then, it is keeping the c the l and the t, and also the v, the h and the k. Then, it is cutting out the e and the ou and is keeping the tr." And them, the following set of characters is telling it how to apply the instructions, correct? This is fun, I am just not an expert on it...really, just getting started in it. But the ? means to eliminate something, right? Or to make it optional, or soemthing like that, right? Ok, anyway...just thought I would explain what I thought I understood it to mean. Would you like me to show you the RegEx I end up coming up with if it is much different from what is here? Afterall, there is not much mor beautiful than a well-constructed RegEx. :-)

At any rate, thanks for your answers. I think I am going to get the Cookbook. I am pretty sure I already have the Mastering Regular Expressions somewhere at home, and the Cookbook sounds really good. The pocket reference sounds interesting and like it may be a good thing to have, but I am afraid I might need more once I really get into it. And probably more complex stuff, too.

57 Comments

The "?" makes the preceding item optional - i.e. it can be there, but it doesn't have to be.
Except, a "?" following a "(" means a "special group" - e.g. a lookahead, or a non-capturing group, or an atomic group.

I'll explain the rest by commenting the regex, hopefully this helps make most sense.

## a word boundary, to make sure we match e.g. "lace" but not "place".
\b
 
## a positive lookahead to make sure we have one of the five words
## this means the rest of the expression wont match random combinations of letters
## without this part, the regex could match "sack" or "liver" or "seather"
(?=lace|silk|velvet|velour|leather)
 
## Capture Group 1, the first letter of the word.
([lsv])
 
## Match the second letter or the word
## Optionally allow an 'a' for "leather"
## Not inside a group because we don't need to keep them.
[aie]a?
 
## Capture Group 2, the third and an optional fourth letter.
([clt][vhk]?)
 
## Match the fifth/sixth letter(s)
## either "e" (velvEt,leathEr) or "ou" (velOUr)
## Uses a non-capturing group (?: ... ) though could have done "[eo]?u?" instead.
## The whole group is optional, because lace,silk don't have five letters.
(?:e|ou)?
 
## Capture Group 3, the sixth/seventh letter (if any).
## The letter itself is optional, rather than the group,
## because we'll want an empty group 3 for the replacement.
([tr]?)
 
## After all the letters, ensure another word boundary, to avoid "silky" being matched.
\b

The "\1\2\3" in the replacement text are references to the three captured groups in the match.

It doesn't so much "eliminate" or "cut out" letters, as it only captures the letters it wants, and then replaces the whole thing with those ones. (Functionally that's the same thing, but the way of going about it differs slightly).

Does all that make sense?

57 Comments

Ah, I noticed a slight bug - the lookahead part should be this:

(?=lace\b|silk\b|velvet|velour|leather)

Otherwise it could incorrectly match "laceer" or "silkout", etc.

(The other three items there are long enough not to need word boundaries, but it wouldn't hurt to add them on either.)

383 Comments

ahhhhh, ok! @Peter...yes, that makes sense now...thanks so much! I like the boundaries. :-) I used them in my submission. It's a neat thing. Quick question about the boundaries, though, even though I think I know the answer...can you have nested boundaries. I'm not trying to be a pain in the butt...just curious. Very elaborate solution. I like it. :-)

383 Comments

although I realize it is completely unsophisticated, tacky, unrefined, and idiotic, couldn't you do nested RegExp Repaces, for example, putting a RegExp Replace inside a RegExp Replace inside a RegExp Replace, and so on? For example:

regexp_replace(CLOTHING_CLASSIFICATION_LIST,'lace','N-C'),'CENTRAL','C'),'NORTH','N'),'SOUTH','S') as clothClassDispList

I realize that is tacky, but it is do-able, isn't it? And I do like @Peter's solution better, I just thought I'd write and see if this was do-able at all?

15,640 Comments

Yeah, as you two (@Anna, @Peter) were saying, a dictionary-like replacement approach requires you to run logic on every match individually; something that, as you have seen, the base reReplace() functionality does not readily let you do. It will be very interesting to see how this changes with the announced Closure functionality to be provided in ColdFusion 10.

As an aside, because regular expressions are so complex, sometimes I find it easier to "dumb down" the patterns and then do more logic on each match. But, each situation is different.

As @Peter was saying, I do have a number of regex utility code in ColdFusion. Some of the more recent ones that jump to mind that would probably help you iterate / augment matches:

PatternMatcher.cfc:

www.bennadel.com/blog/2097-PatternMatcher-cfc-A-ColdFusion-Component-Wrapper-For-The-Java-Regular-Expression-Engine.htm

This is basically the core match-iteration functionality. It sits on top of the Java Pattern and Matcher objects and provides a somewhat simplified and augmented API to the objects. Plus, you don't have to worry about any Java type casting (ie. javaCast()) when talking to the API.

Before I made that, my prior attempts to make looping a bit easier on pattern matches:

www.bennadel.com/blog/971-RELoop-ColdFusion-Custom-Tag-To-Iterate-Over-Regular-Expression-Patterns.htm

Anyway, I know I'm a bit late to the conversation. Just thought I would put these out there.

15,640 Comments

@Anna,

Nested reReplace() calls can work. But for you sanity / maintainability, I much prefer multiple CFSet tags in which one the results of one reReplace() are stored in intermediary variables (even if it's the same one being overwritten each time).

383 Comments

@Ben,

Thank you for your input and for those link suggestions. I know it sounds odd, but I love nested things. I won't show my nested solution that I have developed, although there isn't too much nesting involved (just a little bit...but I don't always have to have nesting).

I'm too dumb to dumb down the patterns...sorry...but I am going to go and read the information from the link you posted. Maybe that will help. I am sure I will gain plenty from it and grow intellectually. :-)

383 Comments

I have question...it's probably a weird one, but here goes: I know that it is the optimal solultion to do processing/calculation/etc. using the database, but is there ever a situation where it is faster/more efficient in terms of processing/better just to go ahead and use the utilities ColdFusion gives us to do what we need to do? An example relates to the above -- one of the reasons I asked about RegEx's was because I was trying to use the oracle RegExp utility to process the data I was pulling. Several of the answers would rely more on cold fusion, such as

<cffunction name="listMaterialNames" returntype="string">
<cfreturn "lace|silk|velvet|velour|leather" />
</cffunction>
 
<cffunction name="convertMaterialName" returntype="string">
<cfargument name="MatchText" />
<!--- translate Arguments.MatchText into short version. --->
<cfreturn ShortVersion />
</cffunction>
 
Which calls a function for every match, and that function call could use any CFML logic to lookup what the short version could be

and

multiple CFSet tags in which one the results of one reReplace() are stored in intermediary variables

(I'm sure there are others)

Anyway, going back to my question, are there times when, from a performance standpoint, there are better solutions using either cf or a combination of cf and/or the database?

The question pertains to something I am doing now. The earlier question was about another part of the project, but I've moved on and this one is slightly different. And the rason I ask the question is because I have run these queries in the database and compared the time it takes to run, and I can't help but think there may be a way to use ColdFusion and/or a combination of ColdFusion and the database I am using (which is oracle, btw), to do this quicker. I have figured out two ways to write the query, and one is yielding a run time of 2 minutes, the other 23 seconds. Using oracle, there seems to be quite a hangup in using the to_date function, or at least in my query that seems to be the case...it seems to be quite an expensive little function in terms of execution time for my query. Am I nuts, or has anyone else run up against this also? Anyway...just a question that kind of relates...I thought I would ask. Thanks!

15,640 Comments

@Anna,

That's an interesting question. Unfortunately, I am not too versed in the regular expression support in databases. I know that there is at least SOME minimal support for while cards and even for some character sets; but, if you want something more advanced than that, I have no idea.

At the end of the day, you just want to make sure you filter as many rows as the database level before you return the record set to ColdFusion; that way, if you do perform further filtering at the ColdFusion level, at least its on a few records as possible.

Sometimes, I will perform "rough" filtering on the database server using something like the LIKE '%...%' directive; then, I'll further filter that with more robust tools on the ColdFusion side. I can't think of a great use-case for such an approach, but I think it typically pertains to text/memo fields where the database tools can be limited (note: some database functions simply can't be applied to long-text fields).

383 Comments

@Ben, thanks for your answer! I went on here to get that groovy regEx pic to put as my avatar, and that's when I saw your answer. :-) I kind of get lost in things sometimes.

As a little background to the project I was working on, we had a recordset returned from the database. For continuity's sake, I will use the following recordset:

Black Lace|Classic Silk|Royal Velvet|Chic Velour|Matte Leather

ok, and say, for the thing we were wanting to convert the above to...we are wanting to create ID's, which have the above in there, but didn't want to have the "whole word" in there...let's say, a product id or label or type or something like that.

So, say we have the Black Lace, and we want it to have parts of the Black Lace in it, followed by something like a randomly generated number or something like that, so we have something for the Black Lace products to the effect of:

BLKLC00293103

and then something like the following for the others:

CLSSLK1109213
RYLVLVT119218
CHCVLR1918292
MTLTHR1928122

ok, just thought I'd give you a little context there.

I have a code reviewer I work with, and what we ended up doing instead is create a lookup table separately for the values we wanted to get and relate them to the other values the blacklace, classic silk, royal velvet, etc.

I had originally been trying to avoid a solution such as that one, because I wasn't sure how much db space I had at my disposal, and I didn't know if they wanted me creating any more tables than what I had to work with. But if that's the way they wanna do it, that's fine with me!

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel