[prev] [index] [next]

Alternation

The notation   pattern1 | pattern2 |  ...  | patternn
  • matches any of the patterni's
  • chooses the first and longest possible match
E.g. a|b|c matches any of the letters a, b or c   (same as [abc])

E.g. ([0-9]+)|([a-z]+) matches any sequence of letters or digits

Note: parentheses are used for grouping i.e. to treat a complex pattern as an atomic pattern.