Menu
I have a string that represents a phone number (1234567890). I am trying to split out the area code and the phone number so I can format it like 123-456-7890. Below is my code, but it never gets past where I am printing out the phone1, and the phone1 is printing blank. Could someone help me with formatting the phone number?
[code]
phone = phone.replaceAll(“[^0-9]”,””);
String areaCode = phone.substring(0,3);
System.out.println(“area code: “+areaCode);
String phone1 = phone.substring(3,3);
System.out.println(“phone1: “+phone1);
String phone2 = phone.substring(6,4);
System.out.println(“phone2: “+phone2);
Thanks