Board index » Visual Studio » regular expression

regular expression

Visual Studio375
Can I use a regular expression to test if the entered value is a 4,6,8 or 10

digit number.

If so, could you write a quick example?



1234

123456

12345678

1234567890



It can only be 4,6,8, or 10 digits long and must be all numbers. No

decimals, signs, or spaces.



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


-
 

Re:regular expression

This will match only numbers with 4 digits.



^[0-9]{4}$



I couldn't find out how to say 4 or 6 or 8 or 10 :)





<thomasp@msala.net>wrote in message

Quote


Can I use a regular expression to test if the entered value is a 4,6,8 or

10

digit number.

If so, could you write a quick example?



1234

123456

12345678

1234567890



It can only be 4,6,8, or 10 digits long and must be all numbers. No

decimals, signs, or spaces.



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access





-

Re:regular expression



How about



^(\d\d){2,5}$



that is, 2 3 4 or 5 groups of two digits.





Robin Tucker wrote:

Quote
This will match only numbers with 4 digits.



^[0-9]{4}$



I couldn't find out how to say 4 or 6 or 8 or 10 :)





<thomasp@msala.net>wrote in message

news:42dbc759$0$29094$b9f67a60@news.newsdemon.com...

>

>Can I use a regular expression to test if the entered value is a 4,6,8 or

>10

>digit number.

>If so, could you write a quick example?

>

>1234

>123456

>12345678

>1234567890

>

>It can only be 4,6,8, or 10 digits long and must be all numbers. No

>decimals, signs, or spaces.

>

>Thanks,

>

>Thomas

>

>--

>Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

>------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

>Unlimited Access, Anonymous Accounts, Uncensored Broadband Access



-

Re:regular expression

Thats the one :)



"Larry Lard" <larrylard@hotmail.com>wrote in message

Quote


How about



^(\d\d){2,5}$



that is, 2 3 4 or 5 groups of two digits.





Robin Tucker wrote:

>This will match only numbers with 4 digits.

>

>^[0-9]{4}$

>

>I couldn't find out how to say 4 or 6 or 8 or 10 :)

>

>

><thomasp@msala.net>wrote in message

>news:42dbc759$0$29094$b9f67a60@news.newsdemon.com...

>>

>>Can I use a regular expression to test if the entered value is a 4,6,8

>>or

>>10

>>digit number.

>>If so, could you write a quick example?

>>

>>1234

>>123456

>>12345678

>>1234567890

>>

>>It can only be 4,6,8, or 10 digits long and must be all numbers. No

>>decimals, signs, or spaces.

>>

>>Thanks,

>>

>>Thomas

>>

>>--

>>Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

>>------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

>>Unlimited Access, Anonymous Accounts, Uncensored Broadband Access







-

Re:regular expression



That worked great



Quote
^[0-9]{4}$

^[0-9]{6}$

^[0-9]{8}$

^[0-9]{10}$



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

-

Re:regular expression



That will suit my need even better.



Thanks,



Thomas



--

Posted via NewsDemon.com - Premium Uncensored Newsgroup Service

------->>>>>>www.NewsDemon.com<<<<<<------">www.NewsDemon.com<<<<<<------

Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

-