Regular Expressions

Regular expressions… and I’m not talking about the ones you normally text with. It is an apt name however, due to it being something I use on a very “regular” basis.

My Initial Expression

When I first stumbled across regex, my initial expression was one of boredom. Let’s be honest, regex doesn’t exactly boast of the latest and greatest or the newest and coolest. Plus, it was officially first used in perl when I was like -13 years old… pretty sure CDs weren’t even a thing at that point. So who cares? Why not spend the time learning redux, or the newest task runner or bundler?

The Test of Time

Although it’s been around a long time, I would bet that it’s probably one of the most commonly used tools whether you know it or not. Just dig into any URL rewriting, the core of WordPress, or all of the find and replace tools out there. Behind the scenes regex has saved hours of work, and been implemented in one facet or another to all major development tasks or endeavors.

Alright, I get the history, so what does it do?

Regex, in a nutshell, is way to add logic to find-and-replace or pattern match — a “mapping” that allows you to be able to logically decipher a string into various pieces or patterns. What this does is, it allows your application to be able to quantify things like URLs, log messages, or anything else where you may want to extract specific pieces or patterns, but aren’t always sure what the contents of those strings might be.

For example, most web servers use pattern matching for their URL parsing. So when you see a URL: “” this gets matched by the webserver to tell it which web directory and post you want to view. WordPress will then extract the pieces from the URL using pattern matching to determine the post type, post name, page index of a blog feed, category, etc. Those extracted pieces get turned into variables like “” etc.

Going Beyond the Behind-the-Scenes

All that is cool to know, but it becomes a lot more applicable when you realize regex is usable in all the languages I’m aware of, as well as most find-and-replace tools including Atom, Google Spreadsheets, etc! It also becomes very handy when you need a customized permalink structure for a client and you want to make it fit in with WordPress’s pretty permalinks, or you have a massive file of log messages and want to extract specific parts in your text editor.

Here are some awesome tools and tips to learn more:

Level Up Your Editor

Ahh, the text editor. One of the most prized developer possessions. And like any machine, you gotta look under the hood to see why no two are the same. We all have “our” theme, “our” packages, “our” snippets, etc.

One of the best ways I’ve improved my environment has been primarily by reading what other people appreciate and utilize in their workflow. I’d still like to improve my workflow, and have even been considering giving VS Code a test drive. So, keeping in line with my goal for the blog, here is my attempt to give back and share what I use.

Continue reading “Level Up Your Editor”

WP Engine: Post Launch Development

I recently ran into a situation when working with a site on WP Engine post going live. It was a bit of a struggle and I decided to come up with something better. I knew WP Engine had git push options, and had used them before, but that was only one of the pieces I needed for a more seamless workflow.

If you’re like me, you have a process for how you develop custom websites. It usually begins with your local development environment, version control of your code, and shared database for collaborative development etc…

However, that environment can tend to go quickly down the drain once a site goes live. You’re now at the mercy of the client-chosen hosting provider, never sure if your local or staging versions of the site are in true alignment with the live site, and every small edit from then on leaves a bad taste in your mouth on the site you put so much effort, organization, and passion into.

Continue reading “WP Engine: Post Launch Development”