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 {
    /**
     * s is a phone number or not
     */
    public static boolean isPhoneNumber(String s) {
        String pattern = "^((13[0-9])|(14[5,7])|(15[^(4,\\D)])|(17[0,6,7,8])|(18[0-9]))\\d{8}$";
        Pattern phone = Pattern.compile(pattern);
        return phone.matcher(s).matches();
    }
}