正则表达式匹配字符长度

/**
 * 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;
    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值