I have validated my regex from regex storm
My pattern is: ([A-Z])([A-Z])([A-Z])-([0-9])([0-9])([0-9])
which simply validates a string with patter XXX-123
I have the following program:
Regex regex = new Regex(@"([A - Z])([A - Z])([A - Z])-([0 - 9])([0 - 9])([0 - 9])");
private void planeIdentityTB_TextChanged(object sender, EventArgs e)
{
Match match = regex.Match(planeIdentityTB.Text);
if (!match.Success)
{
isPlaneIdValid = false;
planeIdentityTB.BackColor = Color.Red;
} else
{
isPlaneIdValid = true;
planeIdentityTB.BackColor = Color.White;
}
}
The match is never successfull. I think i am making a silly mistake. But i am not being able to see it. Can anyone help me?