开发者

How to write regex for "at least 50 symbols"?

开发者 https://www.devze.com 2023-03-29 20:09 出处:网络
I 开发者_运维问答need regex for Regular Expression Validator in ASP.NET, that user need to write in message at least 50 symbols(characters). How to do it? I tried

I 开发者_运维问答need regex for Regular Expression Validator in ASP.NET, that user need to write in message at least 50 symbols(characters). How to do it? I tried

.(dot){50,} but it doesn't work.


.{50,} seems a correct RegExp to me.

However, I think, the regular expression is only checked if the field is not empty, and empty strings are considered valid, so you need to couple this with a RequiredFieldValidator.


This one should work.

<asp:RegularExpressionValidator ID="Validator1" runat="server" 
 ControlToValidate="TextBox"
 ErrorMessage="Minimum length is 50"
 ValidationExpression=".{50}.*" />


This works for me

/^[a-zA-Z0-9]{50,}$/
0

精彩评论

暂无评论...
验证码 换一张
取 消