More

Regular expressions have nearly infinite depth, and this appendix has barely begun to scratch the surface, either of expressions or the ways you can use them in Ruby and Rails. A few of the things this incredibly brief guide hasn’t been able to include are:

  • Using expressions to fragment a string into smaller pieces

  • Referencing earlier matches later in an expression

  • Creating named groups

  • Commenting regular expressions

  • A variety of special syntax forms using parentheses

Again, for a much more comprehensive guide to regular expressions, see Jeffrey E. F. Friedl’s classic Mastering Regular Expressions or Tony Stubblebine’s compact but extensive Regular Expression Pocket Reference. For more on using them specifically with Ruby, see The Ruby Programming Language, by David Flanagan and Yukihiro Matsumoto (O’Reilly).

Get Learning Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.