Learn AP Comp Sci

☰

Problem of the Day

Friday, September 25, 2026


Problem:

A collection of addresses is given in the form shown here:

375 Via los Miradores Ave, Redondo Beach, CA 90277
1414 W Union St, Pasadena, CA 91003
23412 N Lake Ave, Denver, CO 80204

A dot . matches any character. a ^ matches the beginning of a line, and a $ matches the end of a line. Which pattern will match just the 5 digit zipcodes in the list of addresses above?

  1. ^.....$
  2. .....
  3. .....$
  4. ^.....

Show solution:

The correct answer is c.

The 5-digit zipcodes are located at the end of each line. Five dots would match a pattern of five characters anywhere on each line, but five dots at the end-of-line $ will only match the five characters at the end of each line.