All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qwlabs.lang.Mobiles Maven / Gradle / Ivy

There is a newer version: 0.2.354
Show newest version
package com.qwlabs.lang;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.regex.Pattern;

public final class Mobiles {
    private static final Logger LOGGER = LoggerFactory.getLogger(Mobiles.class);
    private static final Pattern PATTERN =
            Pattern.compile("^1(3\\d|4[5-8]|5[0-35-9]|6[567]|7[01345-8]|8\\d|9[025-9])\\d{8}$");

    private Mobiles() {
    }

    public static boolean isMobile(String mobile) {
        try {
            return PATTERN.matcher(mobile).matches();
        } catch (Exception e) {
            LOGGER.warn("invalid mobile", e);
            return false;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy