(...) is grouping; e.g. ab* matches "a", "ab", "abb", etc. whereas (ab)* matches "", "ab", "abab", etc.; ^foo|bar$ matches "foo" at the beginning of a line or "bar" at the end, whereas ^(foo|bar)$ matches either "foo" or "bar" as a whole line; a backslash followed by the number of the group (starting from 1) can be used later in the pattern to refer back to what it (actually) matched; e.g. [a-z]{2} matches "aa", "ab", "za", etc. whereas ([a-z])\1 matches "aa", "bb", etc. (but not "ab" or "za").