RegularEx pressionValidator.ValidationEx pression强制长度在10或12个符号符号、长度、ValidationEx、RegularEx

2023-09-03 17:26:35 作者:Acolasia(放纵)

RegularEx pressionValidator.ValidationEx pression =\ D {10}只意味着数字 - 10最大值

RegularExpressionValidator.ValidationExpression="\d{10}" means only digits - 10 max.

RegularEx pressionValidator.ValidationEx pression =\ D {10,12}只意味着数字 - 10,11或12

RegularExpressionValidator.ValidationExpression="\d{10,12}" means only digits - 10, 11 or 12.

如何强制严格的10个或12个符号?

How to force strictly 10 or 12 symbols?

推荐答案

^ \ D {10} $ | ^ \ D {12} $

两个 ^ $ 如果你想要一个准确的10或12位数字是非常重要的。

The two ^$ are important if you want an exact 10 or 12 digits.

顺便说一句,如果你是做了很多的正则表达式的这个网站是伟大的: http://rubular.com/

By the way, If you are making a lot of regexp this website is great : http://rubular.com/

玩得开心