正则表达式检查第一个字符是否为大写 [英] Regex to check if the first character is uppercase

查看:116
本文介绍了正则表达式检查第一个字符是否为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检查用户名的第一个字符是否为大写,以下内容可以是字母或数字,最多20个字符。有人可以解释为什么我的语法错了吗?

I'm trying to check that the first character of a username is capital, the following can be letters or numbers and at most 20 characters long. Can someone explain why my syntax is wrong?

/^[A-z][a-z0-9_-]{3,19}$/


推荐答案

你的第一个Z不是大写字母Z 。

Your first Z is not a capital Z.

/^[A-Z][a-z0-9_-]{3,19}$/

这篇关于正则表达式检查第一个字符是否为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆