How to allow user to enter string only in small case using regex?

By James J

Allow users only to enter small case string & validate it by regex...

private void button1_Click(object sender, EventArgs e)
{
          
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^[a-z]$");
            
if (regex.IsMatch(textBox1.Text))
            {
                 MessageBox.
Show("Value is correct.");
            }
            
else
            {
                 MessageBox.
Show("Value is not correct.");
            }
}

How to allow user to enter string only in small case using regex?  (564 Views)