I want to get user input for telephone numbers. I have 2 number categories Golden and Normal. When the user enter certain pattern of a telephone number, the system will automatically determine it as Golden or Normal. I'm having problem to code certain pattern. One of the Golden Pattern number is like this: AB001234 where AB is number like 12,23,34,45,56,67,78 and 89. Here what I got so far.
public static void main(String[] args) {
Scanner userinput = new Scanner(System.in);
System.out.println("Enter Telephone Number");
String nophone = userinput.next();
String Golden = "(\\d)(\\1)002345|(\\d*)12345$";
//I want to add AB001234 pattern to the line above but I don't know how.
if (nophone.matches(Golden)) {
System.out.println("Golden");
}
else {
System.out.println("Normal");
}
}
I'm not sure do I really have to use regex or not. One more question, you can see the first part of String Golden is without $ while the second part has $. I'm not sure the effect if I put or remove the $ symbol.