Hello Guys,
I am developing windows application using C#.
Can we use regular expression validation in windows application? How?
I want a string which contain starting 5 char Alphabets then 4 char numeric and 1 char Alphabet in sequence.
Regards,
Zuber Kazi
Loading
Jignesh TrivediPosted Feb 13, 2012, 2:58 AM
yes, u can use regular expression validation in windows application.
Try...
string stringInput = "testw1234s";
Regex myPattern = new Regex(@"[A-Za-z]{5}\d{4}[A-Za-z]{1}");
bool a = myPattern.IsMatch(stringInput);
also refer
http://www.codeproject.com/Articles/10093/Validators-for-Windows-Forms-ValidationProvider-Co
hope this help.
VulpesPosted Feb 13, 2012, 9:48 AM
Zuber KaziPosted Feb 13, 2012, 2:51 AM
Match m = Regex.Match(str, "[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9][a-zA-Z]");
if (m.Success)
MessageBox.Show("valid");
else
MessageBox.Show("invalid");