STATE MACHINES AND REGULAR EXPRESSIONS PLEASE DOUBLE CHECK, AND VERIFY YOUR ANSW
ID: 3840336 • Letter: S
Question
STATE MACHINES AND REGULAR EXPRESSIONS
PLEASE DOUBLE CHECK, AND VERIFY YOUR ANSWER BEFORE SUBMITTING.
You have been hired by Gell - a company that builds computers and electronic devices to help them build a new warranty self service portal. One of your tasks is to an up-front validation of the serial number entered on the web site before we go to the database to get the specifics on this computer/device. Unfortunately, each division of the company has a different idea on what a serial number should look like. The System Architect has decided that you need to create a single regular expression that will match ONLY the following serial number patterns:
Computer serial numbers start with a consonant, then a vowel (never y), a dash, then 6 digits.
Examples: XA-123456 CU-987654 BO-062021
GPS's have 1-8 digits then 2-4 characters.
Examples: 1BB 18273645QZ
Toys use 5 digits, a comma, then 5 more digits.
Examples: 12345,98765 35481,01257
Cell Phones use a three digit carrier code, a colon, two characters, a greater than sign then 7 digits.
Examples: 321:BB>1234567 332:QG>3948571 All letters are upper case. Please test your regex thoroughly.
Explanation / Answer
computer serial number:
*([b-df-hj-np-tv-z]{2})([aeiou])('-')([1-9]{6})$
GPS's
*([1-9]{1,8})([1-9]{2.4})$
Toys
*([1-9]/{5})(',')([1-9]/{5})$
Cell phone:
*([1-9]/{3})(':')([a-z]/{2})('>')([1-9]/{7})$
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.