简体   繁体   中英

Regular expression fixed digit size in my expression

I have a expression that I want to add another function to it.

Now I can type 0736544565 10 digits And +46736589787 11 digit with a + at the beginning.

In the expression you have to begin with 07 or +467 an then any digit. I want to fix the size to but I have problem to put the condition in the expression. When it starts with 07 I want to limit it/fix size on the digit to 10 digits when it starts with +467 I want to limit it/fix size on the digit to 12 digit or 11 without the +

My expression: ValidationExpression="^(07).+|(\\+?467).+">

How do I put this condition in the expression?

怎么样:

ValidationExpression="^(07|\+?467)\d{8}$"

What about using a regex like:

^07\d{8}\b|^\+?467\d{8}\b

Essentially 8 digit following the prefix you had mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM