logo

Crowdly

As part of securing a web site you are tasked with developing a regular expressi...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

As part of securing a web site you are tasked with developing a regular expression that can be used to validate flight ticket numbers as entered by users. The flight ticket numbers have the following format:

AA-NN[N][N]-YYYY-MM-DD-CCCCCC

The different fields are explained below:

  1. AA is a two character upper case airline code where each character can be from the whole alphabet (we won't need stricter checking here as in actually checking for valid 2-character airline codes)
  2. NN[N][N] is a flight number which is either 2, 3 or 4 digits long (note that the square brackets here indicate that the 3rd and 4th digits are optional and the square brackets are not part of the format)
  3. YYYY is the year, assume we accept all values between 2000 and 2099
  4. MM is the month, this is always specified as two digits (with leading 0 if necessary)
  5. DD is the day of the month specified as two digits (with leading 0 if necessary)
  6. CCCCCC is a 6 digit number

All these fields are separated by hyphens.

For the purpose of the exercise, you do not need to consider valid year/month/day combinations and you only need to check each in isolation. For example, 2021-09-31 is valid here. However, your solution must NOT explicitly list all the valid numbers for years, months or days.

You must explain your solution, but no more than one short sentence (or bullet point) for each of the fields.

More questions like this

Want instant access to all verified answers on moodleprod.murdoch.edu.au?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!