Skip to content

Terminal - SORT-O-MATIC

Terminal

Terminal


  • Elf: Pepper Minstix
  • Location: Front Lawn
  • Related to Objective: 4

Terminal

Link: regular expression cheat sheet, this regex test interface.


The goal of this terminal challenge is to teach you about regular expression (Regex). The hint for this terminal challenge is available in the hint section.

You need to write 8 Regex expressions to ensure toys are sorted into the correct groups, The Island of Misfits or Santa's Bag. Here are the 8 things you need to write a Regex for:


Terminal


Answer

Here are the answers for each challenge:

1) Matches at least one digit

\d+

2) Matches 3 alpha a-z characters ignoring case

[a-zA-Z]{3}

3) Matches 2 chars of lowercase a-z or numbers

[a-z \d]{2,}

4) Matches any 2 chars not uppercase A-L or 1-5

[^A-L 1-5]{2,}

5) Matches three or more digits only

\b\d{3,}\b

6) Matches multiple hour:minute:second time formats only

^([0-5]\d):([0-5]\d):([0-5]\d)$

7) Matches MAC address format only while ignoring case

\b([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})\b

8) Matches multiple day, month, and year date formats only

\b[0-3]\d[/ . -][0-1]\d[/ . -]\d{4}\b

Once you complete the challenge you get the following message:


Terminal