Advanced regex vocabulary

  • Capturing group () — captures submatch; (?:...) = non-capturing; (?<name>...) = named
  • | alternation — matches one full alternative (cat|dog); [...] = single character from a set
  • (?=...) positive lookahead; (?!...) negative; zero-width (doesn't consume chars)
  • \\b — word boundary; ensures match is a whole word, not part of a larger word
  • Greedy vs lazy: + grabs as much as possible; +? grabs as little as possible

Question 0 of 5

What does the capturing group do in this regex? /^(\d{4})-(\d{2})-(\d{2})$/