I have a doubt with a problem that I have to resolve in Java. The thing is: my program receives two arguments by console, the first one is the file's path where I have to load this file to the java program, It's a .ini file. The second argument is a code, with this pattern: XXX-XXXX or XXX-XXXX-XXXX where 'X' are numbers from 0 to 9. Here in the second argument my problem comes in: I have to use the packet java.util.regex to implement this pattern, I mean, I have to validate that the user input the arguments properly. How can I do this? The part of my code that implements this is the following, thanks in advance:
Pattern patron = Pattern.compile("^[0-9]{3,}"); //aqui va la regex que queremos poner
Matcher match = patron1.matcher(args[1]);
if(args.length < 2){ // el programa espera recibir dos argumentos
System.out.println("ERROR, número de argumentos inválido!");
System.exit(1); //termina el programa
} else if(args[0].endsWith("config.ini") == false){ //COMPLETAR la segunda condicion
System.out.println("ERROR, los argumentos no toman valores válidos");
System.exit(1);
}