Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String args[]) {
        String phone = "(111)-111-1111";
        String phoneNumberPattern = "(\\d-)?(\\d{3}-)?\\d{3}-\\d{4}";
        System.out.println(phone.matches(phoneNumberPattern));
    }
}