@@ -0,0 +1,1799 @@
+package java_problems.strings;%0D%0A%0D%0Aimport java.util.*;%0D%0Aimport java.util.regex.*;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * Regular expressions (regexp) help us match or search for patterns in strings.%0D%0A * In this problem, you will be given a username. Your task is to check whether%0D%0A * that username is valid. A valid username will have the following properties:%0D%0A * %0D%0A * The username can contain alphanumeric characters and/or underscores(_).%0D%0A * The username must start with an alphabetic character.%0D%0A * 8 %3C= %7CUsername%7C %3C= 30.%0D%0A * To simplify your task, we have provided a portion of the code in the editor.%0D%0A * You just need to write down the regex pattern which will be used to validate%0D%0A * the username input.%0D%0A * %0D%0A * Input Format: %0D%0A * The first line of input contains an integer N, representing the number of%0D%0A * testcases. Each of the next N lines contains a string that represents a%0D%0A * username.%0D%0A * %0D%0A * Constraints: %0D%0A * The username consists of any printable characters.%0D%0A * %0D%0A * 1 %3C= N %3C= 50%0D%0A * %0D%0A * Output Format: %0D%0A * For each username, output Valid if the username is valid; otherwise, output%0D%0A * Invalid.%0D%0A * %0D%0A * Sample Input: %0D%0A * 4%0D%0A * alpha_naheed%0D%0A * xahidbuffon%0D%0A * nagib@007%0D%0A * 123Swakkhar%0D%0A * %0D%0A * Sample Output: %0D%0A * Valid%0D%0A * Valid%0D%0A * Invalid%0D%0A * Invalid%0D%0A */%0D%0Apublic class JavaRegex3 %7B%0D%0A%09%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner in = new Scanner(System.in);%0D%0A%09%09int testCases = Integer.parseInt(in.nextLine());%0D%0A%09%09%0D%0A%09%09while (testCases %3E 0) %7B%0D%0A%09%09%09String username = in.nextLine();%0D%0A%09%09%09String pattern = %22%5E%5BA-Za-z_%5D%5C%5Cw%7B7,29%7D$%22;%0D%0A%09%09%09Pattern r = Pattern.compile(pattern);%0D%0A%09%09%09Matcher m = r.matcher(username);%0D%0A%0D%0A%09%09%09if (m.find()) %7B%0D%0A%09%09%09%09System.out.println(%22Valid%22);%0D%0A%09%09%09%7D else %7B%0D%0A%09%09%09%09System.out.println(%22Invalid%22);%0D%0A%09%09%09%7D%0D%0A%09%09%09testCases--;%0D%0A%09%09%7D%0D%0A%09%09in.close();%0D%0A%09%7D%0D%0A%7D

Add JavaRegex3