简体   繁体   中英

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.

        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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM