.NET RegEx for letters and spaces

后端 未结 5 833
庸人自扰
庸人自扰 2020-12-16 23:44

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 =          


        
5条回答
  •  鱼传尺愫
    2020-12-17 00:10

    The character class \w does not match spaces. Try replacing it with [\w ] (there's a space after the \w to match word characters and spaces. You could also replace the space with \s if you want to match any whitespace.

提交回复
热议问题