I have the following java class:
public class TesteRG {
public static void main(String[] args) {
String RG = "24.77.195 ssp/pb";
Pattern pattern = Pattern.compile("\d{2}.\d{2}.\d{3}\s\w{3}/\w{2}");
Matcher matcher = pattern.matcher(RG);
if (matcher.find()) {
System.out.println("Valido");
} else {
System.out.println("Não Valido");
}
}
It works, but when I call in the frame it has a jTextField named jTFRG with the following custom code "here is the problem" :
jTFRG = new javax.swing.JFormattedTextField();
try {
jTFRG.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##.### ###/##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
It just lets me enter numbers. How do I insert a String equal to: 12.123.44 SSP / SP
The validation part is working now just need to insert the letters beyond the numbers.
When I try to insert the formatted field, it only lets me put numbers and the value of the String is: 11.11.111 111/11