Posts

Showing posts with the label Regex

Scary Spookvember: Regex!

Image
This is the first blog post in a new series of blog posts that involves me learning and blogging about things that scare developers. I came up with this idea basically right after Halloween ended, so unfortunately this has to be the Scary Spookvember series now instead of Spooktober, which would've made more sense 🤦. This first article is about Regex. Many developers think of it as like a template that can match strings, but actually, Regex is a simple programming language! To show this, let's take a look at a simple Regex that matches a simple lowercase UUID, such as e81dd3ba-44bb-11ec-81d3-0242ac130003 . The Regex that I found on stack overflow is: \b([0-9a-f]){8}-([0-9a-f]){4}-([0-9a-f]){4}-([0-9a-f]){4}-([0-9a-f]){12}\b At first glance, this looks quite confusing and scary, but once we reformat it a bit, things begin to start taking shape: \b # match the beginning or end of a word ( [0-9a-f] # match any character from 0-9 or a-f ) {8} # loop 8 times - # match the...