Added 14 solutions

This commit is contained in:
rshaghoulian
2017-02-09 02:12:38 -08:00
parent dd793be41b
commit 354f4d9abb
26 changed files with 496 additions and 32 deletions
@@ -0,0 +1,23 @@
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/* If a PatternSyntaxException is not thrown by Pattern.compile,
then the regular expression is valid.
*/
public class Solution {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int testCases = Integer.parseInt(scan.nextLine());
while (testCases > 0){
String pattern = scan.nextLine();
try {
Pattern.compile(pattern);
System.out.println("Valid");
} catch (PatternSyntaxException exception) {
System.out.println("Invalid");
}
}
scan.close();
}
}