The 11th Annual Regular Expression Day - June 1st 2018
I can't believe how the time flies! It's just crazy! It's already June 1st - and that means that it's time to show some love to the unsung heros of the programming world: Regular Expressions (aka RegEx). And, to shower praise on the unbelievable power of String-based pattern matching. And of course, what celebration would be complete with out some sweet, sweet prizes (ie, Amazon.com gift certificates)!
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.
Every year, I try to be at least a little creative in honor of Regular Expressions. Usually that means trying to program something that uses Regular Expressions in order to accomplish a task. But, this year, I wanted to go in a different direction - flex a slightly different creative muscle. This year, I wanted to reach back to my "Creative Writing: Poetry" roots and write an ode to the majestic beauty of the RegEx construct.
|
|
|
||
|
|
|||
|
|
|
Now, it's your turn! I'm giving away one $100 Amazon.com gift card and four $50 Amazon.com gift cards. In order to enter to win, you have to write a haiku about Regular Expressions and leave it in the comments below. A haiku doesn't have to rhyme - it just has to be three lines that each have a set number of syllables:
- Line one has 5 syllables.
- Line 2 has 7 syllables.
- Line three has 5 syllables.
The haiku can be in praise of, or in condemnation of Regular Expressions - your choice. Let's see what you can do!
Winners will be selected at random Sunday afternoon (June 3rd, 2018).
Happy Regular Expression day! May this day be sweet and free of catastrophic back-tracking!
Reader Comments
This was a fun exercise, thanks Ben!
Here's my haiku:
Oh RegEx, my friend
All the head scratching you bring
But we still love you
Maybe it's too terse
Maybe unmaintainable
I just copy / paste
At first, you succeed
Heartache surely follows
grief is your solace
To you, it looks smart
To me, vicious evil
Anguish lies ahead
named groups kick ass
match or search act differently
parse all my data
At first, you succeed
knowing, you assume you are
little do you know
They said I shouldn't
use RegEx to parse markup.
I am become death.
I wrote this months ago
Eighty-character regex
Dear Lord, please send help
From Mike Nichols (for some reason he couldn't post):
"You may look behind".
Cryptic past - I look around.
Nobly look ahead.
I have a problem
A regular expression?
My problem's now two
Kleene Code:
Can't infer your point
therefore I must delete you
and call you "rejects"
Haiku number ONE!
slash one slash two slash gee eye
Haiku number two!
A string is never
Too long or complicated
To parse with regex.
Problem arises
Perhaps we can use Regex
We have two problems
slash carrot bracket
a hyphen z bracket slash
start with a letter
Ok. Ok. I was intrigued enough to try.
Huge ass data dump?
Sweet regex to the rescue.
Now I sleep. Good Night.
OK, one more.
Buried in data.
Can't find the patterns, eyes crossed.
Slash slash star, found it!
Delete the third dash
From each of ten million lines
That wasn't so bad
Delete the third dash
From each of ten million lines
That wasn't so bad
Loving the entries so far!! Had some fun this morning as well:
Pluses on pluses:
Catastrophic backtracking!
Don't crash my server.
Look ahead or perhaps behind
The moon is a sub expression of time
A search pattern is etched in the sand
You ask, I answer.
I down-vote. You must accept.
The tag is: RegEx
SObad.
language engines
can differ ever so slightly
frustration abounds
Having some more fun with it!
With POSIX or not,
I'll capture groups in one shot,
Everyone stand back.
@Ben,
Wait - do you get to win your own contest?! I call a fix! LOL :) <3
@Erika,
I'm gonna win all the things!!! :P
Unintended (quotes|comma|space)
Can fritter my (day|week|life) away
Hello debugger
Special characters
Unescaped headaches, hey dude
Hand me the aspirin
Validate phone nums
From 14 diff'rent countries.
What the actual...
Here is my haiku with correct breaks ??
Special characters
Unescaped headaches, hey dude
Hand me the aspirin
@Alice L,
Oh noes! I just realized that the markdown parser I started using today is not turning line-breaks into hard-returns. I can fix that -- it's a setting. Will fix your comment (and the others) in the database.
@All,
Sorry about that -- hard breaks are now upheld. I've fixed the last few haikus since the markdown parser was implemented. woot
^In the beginning
God said, 'Let there be RegEx[p]'
And saw it was good$
Good morning all you beautiful people. Through the power of the Crypto module's pseudo-random number generator in Node.js, I have selected the winners of the RegEx Day 2018 Haiku contest:
Congratulations -- and a huge thank you to everyone who participated. I was overjoyed to see the poems that you all produced! For the selected poems, please send me an email at
ben@bennadel.com
so that we can arrange the Amazon.com gift cards.Happy Monday and have a wonderful week!
@All,
If anyone is interested in how the winners were selected, I published the simple algorithm I used. It's built on top of a cryptographically secure pseudo-random number generator (CSPRNG) in Node.js:
www.bennadel.com/blog/3455-randomly-selecting-regex-day-winners-using-a-cryptographically-secure-pseudo-random-number-generator-csprng-in-node-js.htm
It was an interesting little exercise on its own, because I read up (briefly) about easy it is to create a biased transformation of random bytes, especially in cases where the target values are small (less than 256) as were mine in this scenario. As such, I had to use an npm module that transformed the random bytes in such a way as to avoid bias.
Winners picked randomly?
May the odds be ever in your favor.
Congratulations :-)
@Alice,
Thanks for participating! I'll have to get you next time ;)
@Mark Gregory,
I'm still waiting on your email re: the prize! Don't miss out :D
Ok, I never heard from Mark Gregory -- so, by reason that Alice Mora wrote a Haiku in response to the winner selection, his prize falls through to her.
@Alice,
Please write to me at
ben@bennadel.com
. Cheers!