正则表达式(第一个字符必须是a-z)? [英] Regular Expression (first character must be a-z)?

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

问题描述

你好,



我们想要正则表达式如下:



第一个字符只能是一个-zA-Z

不允许空格和连字符( - )以外的特殊字符



我们写了正则表达式^ [a-zA-Z] [\\\\ - - + +]



< asp:RegularExpressionValidator ID =   rev runat =   server 
ControlToValidate = txtDesignation显示= 动态 Text = ForeColor = 红色
ErrorMessage = 可能是字母数字&第一个字符必须是字母! BackColor = 黄色
ValidationExpression = ^ [a-zA-Z] \S - $ ValidationGroup = insert />







它根据我的要求正常工作,但是,当我们只输入单个字符时,它不接受输入。



你能提出建议吗?

解决方案

ValidationGroup = insert />







它根据我的要求正常工作,但是,当我们只输入单个字符时,它不接受输入。


$ b $你能否提出建议?


 ^ [A-ZA-Z] [A-ZA-Z\s\  - ] * 


Hello,

We want the regular expression like:

First character can be only a-zA-Z
Not to allow special characters other than "space" and "hyphen(-)"

We wrote the regexp like "^[a-zA-Z][\w\s-]+"

<asp:RegularExpressionValidator ID="rev" runat="server"
                                            ControlToValidate="txtDesignation" Display="Dynamic" Text="!" ForeColor="Red"
                                            ErrorMessage="Might be Alphanumeric & First character must be a letter!" BackColor="Yellow"
                                            ValidationExpression="^[a-zA-Z]\S-$" ValidationGroup="insert"/>




It was working properly according to my requirement, but, when we enter only single character it is not accepting to enter.

Can you please give the suggestions?

解决方案

" ValidationGroup="insert"/>




It was working properly according to my requirement, but, when we enter only single character it is not accepting to enter.

Can you please give the suggestions?


^[a-zA-Z][a-zA-Z\s\-]*



这篇关于正则表达式(第一个字符必须是a-z)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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