Practice Problems - Write Code

Please answer the following problems to the best of your ability without any outside help. You can stop working on a problem after you worked on it for about four minutes without solving it.

Problems

Please write a regex that would match both word “gray” and “grey”. Replace “YOUR_REGEX” with your answer, but do not remove other symbols

Please write a regex that would match a word that starts with an uppercase letter and followed by at least one lowercase letters, like “Apple”, “Banana”, or “Carrot”. Replace “YOUR_REGEX” with your answer, but do not remove other symbols.

Please write a regex to capture numbers with 5-7 digits. For example: 48105, 103028, 1234567. Replace “YOUR_REGEX” with your answer, but do not remove other symbols.

Capture words that start with a vowel (a, e, i, o, u), but end with a consonant (any letters that are not a, e, i, o, u). For example, it should match “unicorn”, “it”, and “element”. Replace “YOUR_REGEX” with your answer, but do not remove other symbols.

Please write a regex to replace the ‘YOUR_REGEX’ below to match any price in the form of $3.45 or $23.32 or $400. Note that we are using re.findall(), so please make sure your regex would return the full match string.

Please write a regex to capture a URL that only consists of characters, numbers, underscore, and dots. For example: www.abc.com, def_ghi.com, a678.cn Note that dots(“.”) should not appear consecutively, and should not appear as the first or last character. The dot must appear at least once. Replace “YOUR_REGEX” with your answer, but do not remove other symbols.

What to do next

Click on the following link to go to the post test: Post Test

You have attempted of activities on this page