[英]My RegEx won't allow spaces
I have a regular expression: 我有一个正则表达式:
^[A-Za-z0-9()]+$
this doesn't allow spaces, commas, fullstops, forward slashes or backslashes 这不允许空格,逗号,句号,正斜杠或反斜杠
I am a massive amateur when it comes to this. 在这方面,我是一个庞大的业余爱好者。 Can anyone just tell me how to get it to allow spaces? 谁能告诉我如何获得允许的空间?
Just add a space? 只是添加一个空格?
^[A-Za-z0-9() ]+$
Update for comments: 更新评论:
Sample code: 样例代码:
Regex re = new Regex(@"^[A-Za-z0-9() \\/.-]+$");
var result = re.Match(@"a. z-1\2/");
Console.WriteLine(result.Success);
and gives true
并给出true
您可以将空格与\\s
匹配:
^[A-Za-z0-9()\s]+$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.