Приглашаем посетить
CSS (css.find-info.ru)

Section B.11.  Chapter 12, Regular Expressions

Previous
Table of Contents
Next

B.11. Chapter 12, Regular Expressions

  • Always use the /x flag. [Extended Formatting]

  • Always use the /m flag. [Line Boundaries]

  • Use \A and \z as string boundary anchors. [String Boundaries]

  • Use \z, not \Z, to indicate "end of string". [End of String]

  • Always use the /s flag. [Matching Anything]

  • Consider mandating the Regexp::Autoflags module. [Lazy Flags]

  • Use m{...} in preference to /.../ in multiline regexes. [Brace Delimiters]

  • Don't use any delimiters other than /.../ or m{...}. [Other Delimiters]

  • Prefer singular character classes to escaped metacharacters. [Metacharacters]

  • Prefer named characters to escaped metacharacters. [Named Characters]

  • Prefer properties to enumerated character classes. [Properties]

  • Consider matching arbitrary whitespace, rather than specific whitespace characters. [Whitespace]

  • Be specific when matching "as much as possible". [Unconstrained Repetitions]

  • Use capturing parentheses only when you intend to capture. [Capturing Parentheses]

  • Use the numeric capture variables only when you're sure that the preceding match succeeded. [Captured Values]

  • Always give captured substrings proper names. [Capture Variables]

  • Tokenize input using the /gc flag. [Piecewise Matching]

  • Build regular expressions from tables. [Tabular Regexes]

  • Build complex regular expressions from simpler pieces. [Constructing Regexes]

  • Consider using Regexp::Common instead of writing your own regexes. [Canned Regexes]

  • Always use character classes instead of single-character alternations. [Alternations]

  • Factor out common affixes from alternations. [Factoring Alternations]

  • Prevent useless backtracking. [Backtracking]

  • Prefer fixed-string eq comparisons to fixed-pattern regex matches. [String Comparisons]

    Previous
    Table of Contents
    Next