For the longest time, regular expressions have remained something of an enigma to me. Despite the many, many learning opportunities, across various programming languages, my ignorance of their perplexing syntax usually directed to me toward implementing my own code-based algorithms instead. It's clear that most of the time, such roll-your-own solutions don't cut it performance-wise, and probably end up being just as obscure and difficult to decipher, weeks or months down the road.
During my recent endeavor to learn Python, the need for some sprinkles of RegEx quickly presented itself. This time around, I set out to apply myself, and at least master the basics. While clicking around on the web, in search of quality learning resources, I grew pleasantly surprised at the crop of interactive resources on the subject and would like to highlight two for you. They're a refreshing change from the selection of the many animal-toting books on the matter.
RegexOne.com
RegexOne.com is a delightful donation-supported website that guides you through the basics of regular expressions with a dozen (or so) lessons which are short, to the point, and each capped with an interactive input box. Exercises build on the previous ones to introduce each subsequent concept, highlighting the current match as you type. The little quizzes aren't too hard, and in case you get stuck, the solution is just a click away.
Once you've whizzed through the lessons, you can fall back on 5 language-specific guides:
- C#
- Javascript
- Java
- PHP
- Python
RegEx101.com for on-the-fly testing and debugging
With your freshly harnessed knowledge, hop over to RegEx101.com, an online development, and debugging suite. Your test string will light up with an abundance of helpful widgets, in addition to highlighting matches:
- full match information
- capture groups
- English, context-sensitive translation of what the RegEx statement means
- a quick reference box
- a code generator for 9 languages (Javascript, PHP, Python, C#, Java, Ruby, and Rust)
- a means for sharing and storing your work
In not much more than an hour - with the help of these two free resources - I was able to craft an expression that succinctly extracted the information I needed, without resorting to my own obscure and undoubtedly inefficient one-off algorithm.
Top comments (0)