Hacker Rank
Hacker Rank
4 Complete the code in the editor below by replacing the blank ("________") with a regular
expression that matches valid email addresses according to the criteria above. Locked
code in the editor prints True for each correct match and False for each incorrect match.
5
An example of a valid email is [email protected]. It has as many of each
class of character as possible. The address [email protected] fails for two reasons.
6 First, digits cannot precede the underscore. Second, the domain fails because it is not
hackerrank.
7 Constraints
1 ≤ query ≤ 103
8
1 ≤ string length ≤ 103. Line: 7 Col: 1
9 Input Format Test Results Custom Input Run Submit Code
10
Sample Case 0
11 Sample Input 0
5
12
[email protected]
[email protected]
13 [email protected]
[email protected]
[email protected]
14
Sample Output 0
15
True
True
True
False
False
Explanation 0
1. [email protected] starts with between 1 and 6 lowercase letters and contains zero of
the optional characters, so it's valid.
2. [email protected] starts with between 1 and 6 lowercase letters, is followed by a
single underscore, and contains none of the optional digits, so it's valid.
3. [email protected] starts with between 1 and 6 lowercase letters, is followed by a
single underscore, and is followed by between 0 and 4 digits, so it's valid.
4. [email protected] has valid lowercase letters followed by a valid digit, but the digit
must not precede the underscore.
5. [email protected] has a valid user name, but its domain and extension do not
match hackerrank.com.
https://www.hackerrank.com/test/7ra6fpm5mrq/questions/c8276ohcpl 1/1