[英]Regular expression C# text without number
Please give me advice. 请给我建议。 How to write a regular expression, which allows only letter (without special character or number]? Valid inputs are for example: 如何编写仅允许字母(不包含特殊字符或数字)的正则表达式?有效输入例如:
not allowed for example: 不允许,例如:
I try to write regular expression this way, but without success: 我尝试以这种方式编写正则表达式,但没有成功:
public bool RegexControlProduct()
{
Regex regexObj = new Regex("[a-z]+");
bool foundmatch = regexObj.IsMatch(subjectstring);
return foundmatch;
}
Thanks for your help. 谢谢你的帮助。
If you want to allow anything except numbers, you should do: 如果要允许除数字以外的任何内容,则应执行以下操作:
^[^\\d]+$
however, if you want to match the string in the format shown in your question, you can do: 但是,如果要以问题中显示的格式匹配字符串,则可以执行以下操作:
^[a-zA-Z,\\s]+$
Demo: http://regex101.com/r/iE2dJ9 演示: http : //regex101.com/r/iE2dJ9
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.