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 {
    public static boolean isMobile(String phoneNum) {
        if (phoneNum == null)
            return false;
        return validation("^[1][3,4,5,7,8][0-9]{9}$", phoneNum.replace("+86", ""));
    }

    public static boolean validation(String pattern, String str) {
        if (str == null)
            return false;
        return Pattern.compile(pattern).matcher(str).matches();
    }
}