12/17

7. Flags on Regexes (Chapter 12)

Just some of the regex recommendations:

  • Always use /x -- ie, use whitespace.

  • Always use /m -- ie, ^ and $ mean start and end of line.

  • Always use /s -- ie, . matches newlines.

  • Multi line regexes should use m{}, not //.

  • Use \A and \z to indicate beginning and end of string.

  • Always match arbitrary whitespace if humans have been involved.