开发者

Looking for regex to allow spaces but doesn't allow special characters?

开发者 https://www.devze.com 2023-04-12 11:26 出处:网络
I\'m implementing validation for registration form. One of the field is name, can 开发者_JAVA百科have spaces but I don\'t want users to put any special characters.bool isValid = Regex.IsMatch(name, \"

I'm implementing validation for registration form. One of the field is name, can 开发者_JAVA百科have spaces but I don't want users to put any special characters.


bool isValid = Regex.IsMatch(name, "^[a-z0-9 ]+$", RegexOptions.IgnoreCase);
0

精彩评论

暂无评论...
验证码 换一张
取 消