There's been a number of questions about regular expressions in recent days. The Ruby User's Guide has a small script to highlight regular expression patterns. I found it quite helpful for visualizing regex's, especially while learning them. http://www.ruby-doc.org/docs/UsersGuide/rg/