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 TrivediRank #16 · 50.3K reputationPosted Feb 12, 2012, 9:58 PM EST
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.
Zuber Kazi38 reputationPosted Feb 12, 2012, 9:51 PM EST
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");
VulpesRank #55 · 29.2K reputationPosted Feb 13, 2012, 4:48 AM EST