^[A-Za-z ]+$ this expression working but it is not accepting single space i want to accept one space like 'data base'. ^[A-Za-z ]+$ this expression not taking space it taking like 'database' i want 'data base' like this help me. thank u
A:
white space is represented by \s in Regex. Therefore you would want ^[a-zA-Z\s]+$
Williagi
2009-10-19 08:59:37
No. \s is an an character class which matches [\f\n\r\t\v\x85\p{Z}], so it can take other chars than space.
Rubens Farias
2009-10-19 09:02:41
Williagai said "white space"
Artelius
2009-10-19 09:05:54
yes, but the poster wants a single space
Dave Arkell
2009-10-19 09:12:06
+3
A:
Even if what you had worked as you wanted, it will also match "d a t a b a s e". If you want it to match one space that might (or might not) be in the word, use something like ^[a-zA-Z]+( [a-zA-Z]+)?$
David Johnstone
2009-10-19 09:03:21
+1
A:
should be look like
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="TextBox1"
ValidationExpression="^[A-Za-z ]+$" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator>
^[A-Za-z ]+$
As if you will see in the expression , there is space after small z, and this would allow space
Muhammad Akhtar
2009-10-19 09:04:42
If you have multiple consecutive spaces, your solution will catch that as well, but that is perhaps ok with you.
UlfR
2009-10-19 09:52:10