You are viewing a single comment's thread. Return to all comments →
public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int nLines = Integer.parseInt(sc.nextLine());
while(nLines > 0){ String username = sc.nextLine(); boolean isValid = username.matches("^[A-Za-z]\\w{7,29}$"); if(isValid){ System.out.println("Valid"); } else{ System.out.println("Invalid"); } nLines--; } }
}
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 →
public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int nLines = Integer.parseInt(sc.nextLine());
}