Get startedGet started for free

Detecting invalid values with regular expressions

In the video exercise, we saw that there are a number of ways to detect invalid values in our data. In this exercise, we will use regular expressions to identify records with invalid values in the parking_violation table.

A couple of regular expression patterns that will be useful in this exercise are c{n} and c+. c{n} matches strings which contain the character c repeated n times. For example, x{4} would match the pattern xxxx. c+ matches strings which contain the character c repeated one or more times. This pattern would match strings including xxxx as well as x and xx.

This exercise is part of the course

Cleaning Data in PostgreSQL Databases

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT
  summons_number,
  plate_id,
  registration_state
FROM
  parking_violation
WHERE
  -- Define the pattern to use for matching
  ___ ___ ___ ___ ___;
Edit and Run Code