I want to validate an identification format using Java.
Examples: UWU/CST/14/0015 or UWU/IIT/14/0025
Here UWU is required, and one of CST or IIT must be present else it is invalid. After that it can have any two digits and then at least four digits in the last section. Please help me in solving this.
package validate2;
import java.util.*;
public class Validate2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner a=new Scanner(System.in);
String l=a.next();
boolean x=l.matches("^uwu\\/\\w\\w\\w\\/\\d\\d\\/\\d\\d\\d\\d");
if (x == false) {
//JOptionPane.showMessageDialog(rootPane, "Enter a valid serviceNO");
System.out.println("NO");
//return false;
} else {
System.out.println("YES");
//return true;
}
}
}