正则表达式匹配字符长度

/**
 * Copyright 2020 Baidu Inc. All rights reserved.
 * Software distributed under the agreements is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITION OF ANY KIND, either express or
 * implied.
 *
 * Projects and/or code snippets can only be viewed and/or modified by
 * chengshanghang for internal usage. No distribution to any other third-party
 * person allowed.
 *
 * Any code modify behaviors must keep this paragraph and no modification
 * is allowed.
 */

package cn.oschina.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

/**
 * 参数校验工具
 */
@Slf4j
public class ParamVerifyUtils {

    private static final String ENT_CODE_REGEX = "^[a-z][a-z0-9-]{3,19}$";
    private static final String ENT_NAME_REGEX = "^[^<>!@#$%&*]{1,30}$";

    private static final String PRO_CODE_REGEX = "^[a-zA-Z0-9-]{2,32}$";
    private static final String PRO_NAME_REGEX = "^[a-zA-Z0-9-_\\s\\u4e00-\\u9fa5]{1,8}$";

    //验证字符长度1-32位
    private static final String PRO_NAME_LENGTH_REGEX = "^[\\u4e00-\\u9fa5-\\w]{1,8}$";
    //验证字母、数字、下划线字符长度1-8位
    private static final String PRO_NAME_LENGTH_REGEX2 = "[\\w]{1,32}";
    //验证中文字符长度1-8位
    private static final String PRO_NAME_LENGTH_REGEX3 = "^[\u4e00-\u9fa5]{1,8}$";
    //验证任意字符长度1-8位
    private static final String PRO_NAME_LENGTH_REGEX4 = "^.{1,8}$";

    private static final String REPO_NAME_REGEX = "^[^<>!@#$%&*\\u4e00-\\u9fa5]{1,30}$";

    private static final String CODE_USER_NAME = "[<>!@#$%&*\\u4e00-\\u9fa5]";

    private static final String BAE_PRO_PREFIX = "^[a-zA-Z]{1,}-baeapp-[a-zA-Z0-9]{12}$";

    // 英文,中文,数字,中横线,长度[2,32]
    private static final String CONNECTION_NAME = "^[\\u4e00-\\u9fa5a-zA-Z0-9-]{2,32}$";

    public static final Long MAX_PHOTO_SIZE = 2L * 1024 * 1024;


    public static Boolean checkSystemTitle(String systemTitle) {
        if (StringUtils.isBlank(systemTitle) || !systemTitle.matches(PRO_NAME_REGEX)) {
            return false;
        }
        return true;
    }

}

你可能感兴趣的:(正则表达式,p2p,webview)