[英]What the Error in my Regex to to check a string contains a-z or A-Z
here is my code o check whether a string contain any other character than az OR AZ. 这是我的代码,请检查字符串是否包含除z或AZ之外的任何其他字符。
Regex pattern = new Regex("^[a-zA-Z]+$");
if (pattern.IsMatch(txtCustName.Text))
{
MessageBox.Show("Name contains some Invalid Characters");
txtCustName.Focus();
}
It still showing error msg even I'm typing he correct string. 即使我键入他正确的字符串,它仍然显示错误消息。
Regular expression is ok. 正则表达式还可以。 Negate predicate: 否定谓词:
if (! pattern.IsMatch(txtCustName.Text))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.