Coder Social home page Coder Social logo

regular_expression's Introduction

Regular_Expression

正则表达式常用规则

验证用户名

/**
 * 校验用户名
 *
 * @param username
 * @return 校验通过返回true,否则返回false
 */
public static boolean isUsername(String username) {
    return Pattern.matches(REGEX_USERNAME, username);
}

验证密码

/**
 * 校验密码
 *
 * @param password
 * @return 校验通过返回true,否则返回false
 */
public static boolean isPassword(String password) {
    return Pattern.matches(REGEX_PASSWORD, password);
}

验证手机号

/**
 * 校验手机号
 *
 * @param mobile
 * @return 校验通过返回true,否则返回false
 */
public static boolean isMobile(String mobile) {
  return Pattern.matches(REGEX_MOBILE, mobile);
}

验证邮箱

/**
 * 校验邮箱
 *
 * @param email
 * @return 校验通过返回true,否则返回false
 */
public static boolean isEmail(String email) {
    return Pattern.matches(REGEX_EMAIL, email);
}

验证汉字

/**
 * 校验汉字
 *
 * @param chinese
 * @return 校验通过返回true,否则返回false
 */
public static boolean isChinese(String chinese) {
    return Pattern.matches(REGEX_CHINESE, chinese);
}

验证将鞥身份证

/**
 * 校验身份证
 *
 * @param idCard
 * @return 校验通过返回true,否则返回false
 */
public static boolean isIDCard(String idCard) {
    return Pattern.matches(REGEX_ID_CARD, idCard);
}

验证URL

/**
 * 校验URL
 *
 * @param url
 * @return 校验通过返回true,否则返回false
 */
public static boolean isUrl(String url) {
    return Pattern.matches(REGEX_URL, url);
}

验证IP地址

/**
 * 校验IP地址
 *
 * @param ipAddr
 * @return
 */
public static boolean isIPAddr(String ipAddr) {
    return Pattern.matches(REGEX_IP_ADDR, ipAddr);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.