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

I am looking for a Regex which accepts values like shown below:Please help. I tried this
^[a-zA-Z0-9'\s]

but not working. I dont want to accept any symbols other than space.

2565334589
132 258 6589
821222296B01


Thanks a lot.
Posted
Comments
Sergey Alexandrovich Kryukov 20-Aug-13 15:54pm    
You probably meant to say "I dont want to accept any symbols other than blank space, digits and Latin letters"...
—SA

Just try this one:
C#
"^[0-9a-zA-Z ]+$"
 
Share this answer
 
Comments
Maciej Los 20-Aug-13 16:30pm    
+5!
ridoy 20-Aug-13 16:34pm    
Thanks Maciej,:)
Sergey Alexandrovich Kryukov 20-Aug-13 16:42pm    
Same thing, 5ed.
—SA
ridoy 21-Aug-13 1:53am    
Thank you,SA.
ridoy 21-Aug-13 2:03am    
Thank you,SA.
Try ^([a-zA-Z0-9 ])+$.

Probably, you can see you mistakes. You forgot about multiplicity (I used '+' meaning "one or more"), and probably misspelled '$' as 's'. You added a note about blank space below your expression but did not try to include this character.

Note that "alphanumeric" maybe not exactly what I want. As .NET supports Unicode "alpha" may refer to much wider set of letters than Latin characters you tried to allow. :-)

—SA
 
Share this answer
 
v3
Comments
ridoy 20-Aug-13 16:23pm    
+5 SA for explaining it,possibly you and me solve it in same time! :)
Sergey Alexandrovich Kryukov 20-Aug-13 16:43pm    
Yes, thank you. I up-voted yours.
—SA
Maciej Los 20-Aug-13 16:30pm    
+5!
Sergey Alexandrovich Kryukov 20-Aug-13 16:43pm    
Thank you, Maciej.
—SA

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