Appendix F. Patterns for regular expressions

This book demonstrates generators written using Ruby. We understand that for a number of reasons Ruby may not be your language of choice for writing a generator. Because regular expressions are such an instrumental part of code generation, this appendix shows how you can use regular expressions in a variety of languages.

F.1. The examples

Each language implements up to four of the following examples:

  • Checking a string —In this example, we check the string file.txt to see if it has the .txt extension.
  • Reading key/value pairs —This example reads the key and value pairs from the string a:1;b:2;c:3. The correct output is a = 1, b = 2, and c = 3.
  • Replacing tabs with commas —This example turns the ...

Get Code Generation in Action 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.