.NET RegEx for letters and spaces

Posted by user70192 on Stack Overflow See other posts from Stack Overflow or by user70192
Published on 2010-06-01T15:21:24Z Indexed on 2010/06/02 4:53 UTC
Read the original article Hit count: 423

Filed under:
|

I am trying to create a regular expression in C# that allows only alphanumeric characters and spaces. Currently, I am trying the following:

string pattern = @"^\w+$";
Regex regex = new Regex(pattern);
if (regex.IsMatch(value) == false)
{
  // Display error
}

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex