本文介绍了RegularExpressionValidator接受选定的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在客户端验证文本框,该文本框必须包含任何字母或数字或_或-.为此,我这样写了
I want to validate the textbox at client side and it must contain any alphabet or number or _ or -. So to do that I wrote like this
ValidationExpression="^[0-9a-zA-Z_\-]$"
但是它没有我想要的...
PS:REGEX不好:(
but Its not working as I want...
PS : not good in REGEX :(
推荐答案
但是它没有我想要的...
PS:REGEX不好:(
but Its not working as I want...
PS : not good in REGEX :(
^[0-9a-zA-Z_\-]+
注意"+".这意味着前一个或多个".您可能需要改用"*",这意味着前导0或更多"(将匹配一个空字符串).
Notice the "+". That means "1 or more of the preceeding". You might want to use "*" instead, which means "0 or more of the preceeding" (that would match an empty string).
这篇关于RegularExpressionValidator接受选定的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!