People seem to have a strong opinion on regular expressions. While some love them, others avoid using them under all circumstances. Personally, I enjoy writing regular expressions, which is why I want to point out to you Regex Tuesday, a compelling way to improve your regular expression skills.
A Weekly Regular Expression Challenge
Regex Tuesday is the day where everyone writes regex for a day! Every Tuesday, I will push a new challenge to this website. They can be easy or tricky, and there is sure to be a variety of different challenges available.
Depending on the problem, you have to come up with a regular expression that either matches a given selection of the input strings or correctly replaces parts of each string. You're given a bunch of test cases for each problem and are trying to get as many test cases as you can to pass.
Examples for Challenge Problems
Up to the time of writing, past challenges included ...
- highlighting repeated words,
- matching CSS grayscale colors,
- matching dates,
- parsing italic Markdown,
- matching numbers,
- matching IPv4 addresses, and
- matching domain names.
Some of the challenges are harder to solve than others, and since I'm far from being a regular expression expert myself, it took me some time and thought to come up with a solution to some of the problems. (Yes, I'm talking about you, Markdown!)
If you want to save your solutions to the challenges or share your them with others, you can also generate a permalink containing your regular expression.
Keep Practicing Using Your Tools
Regular expressions are one of many tools in a programmer's toolbox. They're definitely not the solution to all problems, but they do have their field of application. Like a hammer, they're not useful when it comes to cutting down trees, when what you really need is an axe. When faced with a nail, though, it'll come in handy to know how to use a hammer. I therefore encourage you to keep improving your regular expression skills and tackle the first week's Regex Tuesday challenge!