Skip to main content
Ben Nadel at cf.Objective() 2010 (Minneapolis, MN) with: Jeff Coughlin
Ben Nadel at cf.Objective() 2010 (Minneapolis, MN) with: Jeff Coughlin ( @jeffcoughlin )

The 12th Annual Regular Expression Day - June 1st 2019

By on

Oh snap, can you feel it? That magic in the air?! Those groovy vibes?! That indescribable feeling of joy and wonderment currently coursing through your veins?! It's June 1st; which means, it's Regular Expression Day 2019!!! Woot woot! That one day of the year in which we take pause and give thanks for the powerful Pattern matching functionality that our programming languages place at our fingertips.

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 hope to be more prepared for this day. Create something clever; a game; a puzzle; some sort of competition. But, for the last few years, I just haven't been able to get it done. But, that doesn't mean I can't spread some joy.

So, this year, I'm giving away one $100 gift card and four $50 gift cards. To be entered for a chance to win, all you have to do is drop a comment below describing a problem you solved with Regular Expressions. Winners will be randomly selected end-of-day Monday.

Happy RegEx Day: Patterns Are Coming! (Game of Thrones spoof)

Happy Regular Expression day! May this day be sweet and free of catastrophic back-tracking!

Reader Comments


Of late I've been doing more work with Docker, which has necessitated writing shell scripts and learning more about the command line (full endorsement of Julia Evans Bite Size Command Line zine - very accesible).

One of the really powerful commands is sed, which can utilize regular expressions (

So, for example, in one instance I use it to set a variable for stepping up and over to a different directory, adjacent to where the script is located.

DIR=$( sed 's+/build+/.secrets+g' <(echo $DIR) )

Regex for the win!


This is a little bit more meta, but once I had to resolve the following problem:

How do you know if two different regex expressions match will match the same set of entries?

For example:

  • /a/ will match "a" without quotes
  • /.*/ will match anything, including "a"

The problem is resolved by converting each regex to a Finite State machine and then computing the intersection of both by generating a third FSM and then converting it back to regex.

I ended up using a open source library for it


Not sure if this will qualify as a proper answer, but... I haven't had my "unforgettable regex moment". It's more of a long-term relationship: don't worry, I'll explain.

See, most regex I've done is - to put it bluntly - uninteresting.
Most patterns I come up with are well-tread paths to solutions that aren't revolutionary in any way. They aren't some flash-in-the-pan, fancy approach. They aren't some new sugar for my syntactical sweet tooth. Rarely are they anything you would draw inspiration from, or that spurns you on as a dev. Were programming analogous to fiction, regex would not be found in that section of the library with titles like "A Night to Surrender" or "40 Nights at Sea".

Rather, regex is unyielding, inflexible, and often stubbornly unforgiving. Yet, it's in those qualities that I find a deeper love for regex: reliable predicably!

Libraries come and go, that form data you're parsing is crazy, and your code style will change over time; yet that regex you wrote remains an obelisk of utility. It just works the same way every time. Consistency is its draw, and it doesn't disappoint.

So, I don't particularly remember any regex I've written. It's all unremarkably the unsung hero of my career, but the hero nonetheless. For that, I owe regex a debt of gratitude.


Graduated as a mathematician, I decided to take a career into programming some years ago.
One of the first assignments I got was to implement a regular expression for parsing social media urls of several platforms.

Not familiar with regular expressions before, I was - and certainly still am - amazed by the power of it!

I believe it was one of my first ever commits in which I composed this regex for parsing the Twitter variant:

When processing the value "" for example, the username would be extracted by the regex and the value be modified to "@BenNadel".



On a recent project, I needed to provide "masked" versions of a user's email address and phone number for display. I was doing this in a ColdFusion app but I achieved my results by dropping down to Java and using replaceAll() on the string.

For the email, I needed to match/replace everything but the first character on the left side of the "@".

emailValue.replaceAll("(?<=.{1})[^@](?=[^@]*?@)", "*");
// Result: t***

For the phone number, I needed to match/replace everything but the last 4 digits in the value.

phoneValue.replaceAll(".(?=.{4})", "*");
// Result: ******8888


Very cool -- I wish my command-line skills were much better. I've never even heard of sed. I can basically do pwd and cd and ls :D Awesome stuff!



100% on point! I agree. RegEx doesn't have to be crazy because it's that tool that you know you can reliably reach for. It "just works". The vast majority of the patterns I write are simple, like (\w+): (\d+) that kind of stuff. But, it just makes life so much easier.



It's always a balance, too. Between things like readability and using non-capturing groups, like your (?:xxx) usage. One of the things I've come to love, though I don't reach for it all that often is the verbose flag (?x). This allows you to break your patterns up over spaces / line-breaks in order to make them easier to understand.


@Matthew, @Hector, @William, @Martijn, @Tony,

Thank you all for participating! This year's turn-out wasn't so great :( which is my fault for not really doing anything all that exciting.

But, the upside to it is that you're all winners! Please email me at and I'll get your Amazon gift certificates out to you. Thank you all :D



Booo for low turnout! Woohoo for winning!

With regard to the command line, I am a complete beginner, but I can't say enough good things about this: - It's extremely practical and makes those incomprehensible man pages actually accessible. If you want something completely different for your next "A Book Apart", or just want to explore the command line, I'd recommend it. Also, in terms of helpfulness, here's another cool reference:

Keep up the awesome blogging! And thanks!



This looks awesome. Julia Evans is a wonderful teacher with her illustrations. I will definitely be checking out this book! Awesome suggestions.

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