Click here to Skip to main content
15,920,677 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to write a regular expression which may enforce input in upper case and one embedded space.
Eg. I want to give me input as "M23 9RQ".

Please help me the regular expression for this input or some other better solution like customer validator etc.

Thanks
Posted
Updated 6-Dec-10 21:53pm
v2
Comments
Dalek Dave 7-Dec-10 3:53am    
Edited for Readability.

1 solution

The regex isn't complex, "([A-Z]|\d){3} ([A-Z]|\d){3}" but why do it that way at all?
Either:
1) Use a masked edit box set to upper case / digits / space as required
or
2) Upper case the input before you use it. That way the user isn't inconvenienced by having to ensure his caps key is on, or he hits the shift, etc. Makes it easier for the disabled, too.
 
Share this answer
 

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