Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Pattern;

public class Main {
    /**
     * Phone number validation Regular Expressions
     *
     * @param input input
     * @return true or false
     */
    public static boolean isPhoneNumber(String input) {
        String regex = "^\\d{7,8}$|^\\d{3,4}-\\d{7,8}$|^1[3|4|5|8][0-9]\\d{4,8}$";
        Pattern p = Pattern.compile(regex);
        return p.matcher(input).matches();
    }
}