Reputation: 73988
I need a validation a texbox in c# and asp.net using Regular Expression.
I need allow:
I need dot NOT allow:
Any ideas? Thanks for your help
Upvotes: 4
Views: 11508
Reputation: 138127
If validation occurs at server side, you can use the pattern:
^\w*(\s\w*)?$
\w
in .Net is Unicode aware - it should include all letters.
Note that \w
also include the underscore and other word-connectors. You can use [\p{L}\p{Nd}]
instead of \w
to disallow them.
See also: Character Classes
Upvotes: 2
Reputation: 10912
This might be a start
^([\w\d]+[ ]?)+$
\d matches the digits
\w matches "word characters". The.NET RegEx considers unicode characters as word characters. See: http://regexlib.com/CheatSheet.aspx
I'm not sure what you mean by "one white space". This expressions allows one space, but not double-spaces, between words.
Upvotes: 3