Valid Username Regular Expression Solution Hackerrank – Java Solution

Hackerrank - Java Solutions Hackerrank Online Judge Solution

Valid Username Regular Expression Solution Hackerrank – Java Solution

HackerRank Problem Solution

Problem Name – Valid Username Regular Expression
Problem Link –  Valid Username Regular Expression
Level – String

Java Only Submitted Code

class UsernameValidator {
public static final String regularExpression = "([a-zA-Z])(\w){7,29}";
}

Java Full Source Code

import java.util.Scanner;

class UsernameValidator {
public static final String regularExpression = "([a-zA-Z])(\w){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");
}
}
}
}

Tags: HackerRank Online Judge Solution, HackerRank OJ Solution list, HackerRank Problems Solution, HackerRank solver, HackerRank all problem solution list, HackerRank solution in java, Hackerrank Java Solution, Welcome to Java!, Valid Username Regular Expression Solution Hackerrank – Java Solution

Leave a Reply

Your email address will not be published.