-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
27 lines (22 loc) · 772 Bytes
/
Solution.java
File metadata and controls
27 lines (22 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// https://www.hackerrank.com/challenges/valid-username-checker/problem
import java.util.Scanner;
class UsernameValidator {
/*
* Write regular expression here.
*/
public static final String regularExpression = "^([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|_){7,29}$";
}
public class Solution {
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int n = Integer.parseInt(scan.nextLine());
while (n-- != 0) {
String userName = scan.nextLine();
if (userName.matches(UsernameValidator.regularExpression)) {
System.out.println("Valid");
} else {
System.out.println("Invalid");
}
}
}
}