Click here to Skip to main content
15,063,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am just learning about regular expressions and I need help finding one to validate a number in a text box that is in the following format

1111 111 11111

Allowed are all numbers and two spaces
not allowed every other character

Can someone help
Posted
Comments
Richard Deeming 28-Jul-15 10:31am
   
Are the spaces always in the same place, or can they appear anywhere in the string?

Try:
^\d{4}\s\d{3}\s\d{5}$
   
Comments
johnjsm 28-Jul-15 10:41am
   
thank you so much. thats working
OriginalGriff 28-Jul-15 10:54am
   
You're welcome!
Assuming any sequence of digits, no leading nor trailing nor consecutive spaces allowed, then the following should do:
^(?:\d+ ){2}\d+$
Cheers
Andi
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900