#K51577. Email Address Validator
Email Address Validator
Email Address Validator
You are given a list of email addresses, and your task is to determine whether each email address is valid based on a specific pattern. An email is considered valid if it matches the following rules:
- The email must be in the form local@domain.
- The local part must start and end with an alphanumeric character (letter or digit). It may contain letters, digits, underscores, hyphens, or dots in between.
- The domain part must start with an alphanumeric sequence and contain one or more segments separated by a dot. Each segment (after the first) should consist of 2 to 4 alphabetic characters.
Formally, an email address is valid if it matches the regular expression below in \(\LaTeX\) format: \[ ^[a-zA-Z0-9]([\\w\\-.]*[a-zA-Z0-9])?@[a-zA-Z0-9]+(\.[a-zA-Z]{2,4})+$ \] Your program should read the input from standard input and print the result for each email address to standard output.
inputFormat
The input begins with a single integer \(n\) (\(1 \leq n \leq 100\)), representing the number of email addresses. Each of the next \(n\) lines contains one email address.
outputFormat
For each email address, print "True" if the email address is valid and "False" otherwise. Each result should be printed on a new line.
## sample2
john.doe@example.com
jane_doe@domain.co.uk
True
True
</p>