You are viewing a single comment's thread. Return to all comments →
import java.util.Scanner; class UsernameValidator { /* * Write regular expression here. */ public static final String regularExpression = "(^\\b\\w{0}[a-zA-Z]\\w{6,28}[a-zA-Z0-9_]\\b$)"; } 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"); } } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Valid Username Regular Expression
You are viewing a single comment's thread. Return to all comments →
My Solution: