Learn AP Comp Sci

☰

Problem of the Day

Monday, September 28, 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

There are a few different expressions that can be used to match patterns in a line of text.

Which pattern will match only the numeric street numbers at the beginning of each address above?

  1. ^\d$
  2. \d\d\d\d\d
  3. ^\d+
  4. \d+

Show solution:

The correct answer is c.

The numeric addresses occur at the beginning of each line, and consist of a series of numbers of varying length. The ^ matches the start of the line, and the expression \d+ matches a sequence of one or more digits.