Vehicle registration plate

Report a typo

Let's now try to write a regular expression that checks whether a given string follows the format of the vehicle registration plates accepted in India. The basic requirements are stated as follows:

  • two uppercase Latin letters
  • they are followed by two digits
  • two uppercase Latin letters again
  • and, finally, four digits

Clusters of letters and digits can be separated by a whitespace character optionally.

Put your regexp in the template variable. Do not forget that you should check whether the entire string meets the requirements, not only the beginning of the string.

Tip: To do that, remember the metacharacters that check for the end of the string.

Write a program in Python 3
import re


# put your regex in the variable template
template = ""
___

Create a free account to access the full topic