12.11. Practice Problems - Regular Expressions

Construct a regex that matches both cat and cats.

Construct a regex that matches abc followed by zero to many digits (0-9).

Construct a regex that matches both gray and grey.

Construct a regex that matches br followed by any single character except for a new line and then a 3.

Construct a regex that matches t.forward.

Construct a regex that matches a word that starts with an uppercase letter followed by at least one lowercase letter, like “Apple”, “Banana”, or “Carrot”.

Construct a regex that matches eight word characters (letter, digit, or underscore).

Construct a regex that matches one or more lowercase letters (a-z) followed by a space character and then two to four digits.

Construct a regex to capture numbers with 5-7 digits. For example: 48105, 103028, 1234567.

Construct a regex that captures strings that have two digits followed by a period and then four letters from a to z.

You have attempted of activities on this page