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

org.gitlab4j.api.utils.EmailChecker Maven / Gradle / Ivy

Go to download

GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.

There is a newer version: 6.0.0-rc.5
Show newest version
package org.gitlab4j.api.utils;

import java.util.regex.Pattern;

public class EmailChecker {

    /** Java regular expression for validating an email address. */
    public static final String EMAIL_REGEX =
        "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"" +
        "(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")" +
        "@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:" +
        "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:" +
        "(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";

    /** Java Pattern instance for validating an email address. */
    public static final Pattern EMAIL_REGEX_PATTERN = Pattern.compile(EMAIL_REGEX);

    /**
     * Returns true if the provided String is a valid email address.
     *
     * @param email the email address to check for validity
     * @return true if the provided String is a valid email address, otherwise return false
     */
     public static final boolean isValidEmail(final String email) {
         return (email == null ? false : EMAIL_REGEX_PATTERN.matcher(email).matches());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy