Beverly Nelson

Regular Expressions without Fear

Have you been avoiding regular expressions because you think they're too confusing? Are you copying and pasting snippets from Stack Overflow into your code but you're not really sure what they mean?

Well, there many great resources available for free that will have you writing regular expressions without fear in no time.

Starting point

In Beneath the Surface: Regular Expressions in Ruby from GoGaRuCo, Nell Shamrell's humor and clear explanation take you through the process of how regex works step by step. If you've used regex to match a string but had no idea how it worked, this is a great starting point.

Tutorials & resources

As a supplement to her talk, check out Nell’s three part post on the Bluebox blog.

Learn Regex The Hard Way from Zed Shaw is a free book online that walks you through Regex mastery using Regetron a simple shell for playing with regular expressions.

If you need something that's a bit more "step-by-step" tutorial, try something like RegexOne for some interactive lessons, real world examples, and a PHP Regular Expressions cheat sheet.

Another student favorite is Rexegg to walk through foundations and more.

Resources to practice

The best follow up for a deep dive talk like this is through practice. If you have a problem you’re trying to solve currently check out one of these Regular Expression editor sites to practice:

  • Rubular - an excellent Ruby regular expression editor & my first choice for testing
  • Regex101 - Regular expression testing in Javascript, Python, PHP
  • Rubyxp - a Ruby regex tester
  • Python Regex Tester - a Python specific regex tester
  • RegexPlanet provides a larger pool of languages you can test in (Go, Haskell, Python, Ruby, Java, Javascript, Perl). In addition, RegexPlanet gives you a cookbook with examples for matching things like Zip Code, Twitter handles, to try things out.

Regex for fun

  • Regex Crossword Interactive regex crossword game with challenges for all skill levels.
  • Regex Golf Regex matching game with 16 levels.
  • Expressions - This interactive game is free for the first 10 lessons with additional levels available for a charge.

Problems to try and solve

If you don't have a current problem requiring regex try one of these to build up some experience:

  • Match a phone number
  • Match a name
  • Reformat a file name
  • Email validation
  • URL validation


Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00