且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式(第一个字符必须是a-z)?

更新时间:2022-11-12 09:19:45

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\-]*