i need a textbox and button
in textbox i have to keep validation in windows form
in text box 1st letter should start with 3
and 2nd letter should start with R||c
I MEAN R OR C
3rd and 4th should be OF||OH||OD
5TH LETTER SHOULD BE B or 0-9
and 6th to 12th it should be a numbers
only
total it should not exceed 12words in textbox

VulpesRank #55 · 29.2K reputationPosted Mar 13, 2014, 2:23 PM EDT
When you say there should not be more than 12 words in the TextBox, I assume you mean that there shouldn't be more than 12 characters but (presumably) at least 6:
using System.Text.RegularExpressions;
// ...
string r = @"^3(R|C)(OF|OH|OD)(B|\d)\d{1,7}$";
bool isValid = Regex.IsMatch(textBox1.Text, r);
Note that the above is case sensitive.
if you want it case insensitive, then change the regular expression to:
string r = @"^(?i)3(R|C)(OF|OH|OD)(B|\d)\d{1,7}$";
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 13, 2014, 1:11 PM EDT
vijay kumar41 reputationPosted Apr 30, 2014, 1:09 AM EDT