Introduction
Here is the source code for MainClass.java
Source
public class MainClass {
public static void main(String args[]) {
String phone = "123-(456)-9999";
String phoneNumberPattern = "(\\d-)?(\\d{3}-)?\\d{3}-\\d{4}";
System.out.println(phone.matches(phoneNumberPattern));
}
}