Kiosk 8: Fixing the Sort-O-Matic

The Sort-O-Matic, located in the workshop, right outside the elevator on the 1 1/2th floor, was broken, sending legitimate presents to the Island of Misfit Toys, and broken toys everywhere else!

Sort-o-matic

Uh oh!

This was a really fun project that sorted presents based on regular expressions. Simply adding the regex allowed the sort-o-matic to put valid presents in Santa's bag, and broken presents get shipped to the Island of Misfit Toys. Since there isn't much of a build-up but rather a series of regex challenges, I will just show the question and the result.

The Challenges

  1. Matches at least one digit

    [0-9]

  2. Matches 3 alpha a-z characters ignoring case

    [a-zA-Z]{3}

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

    [a-z0-9]{2}

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

    [^A-L1-5]{2}

  5. Matches three or more digits only

    ^[0-9]{3,}$

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

    ^([01][0-9]|2[0-3]|[0-9]{1}):([0-5][0-9]):([0-5][0-9])$

  7. Matches MAC address format only while ignoring case

    ^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$

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

    ^([0-2][0-9]|3[01])[\/\.\-]([0-2][0-9]|3[01])[\/\.\-]([0-9]{4})$

And that's it!