FxFormula Drills

Premium Google Sheets drill · Text and regular expressions

REGEXMATCH product codes

Practice Google Sheets REGEXMATCH inside ARRAYFORMULA to test codes shaped like two letters, a hyphen, and four digits.

A code is valid when it is two capital letters, a hyphen, and four digits, such as AB-1044. REGEXMATCH returns TRUE or FALSE.

In B2, test A2:A4 with ARRAYFORMULA and REGEXMATCH. The pattern is case-sensitive.

Dataset

Starter sheet. Cells marked formula are where the formula goes.

Starter sheet for this exercise
RowAB
1Code
2AB-1044Formula goes in B2. formula
3ab-1044
4A-1044

Hint

Use the pattern ^[A-Z]{2}-\d{4}$ with one backslash before the d.

Explanation

AB-1044 matches. ab-1044 fails because [A-Z] does not include lowercase, and A-1044 has only one letter. The three results spill from B2.

The interactive sheet and a worked solution are part of Formula Drills Premium. The instructions and starter data on this page are the full problem.

Solve this drill

Practice this formula

Loading the practice grid…

Google Sheets is a trademark of Google LLC. Formula Drills is not affiliated with Google. Excel drills on this site are a separate track.