Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends good morning

please help me


i want regular expression for this
this is my requirement

AP10B1234(two alphabets two digits 4 digits)


small correction plz dontmind

two alphabets is mandatory next 1 or 2 digits next 1 0r 2 alphabets next 1 to 4 digits
Posted
Updated 8-Sep-11 20:13pm
v3

^[A-Z]{2}([ \-])[0-9]{2}[ ,][A-Z0-9]{1,2}[A-Z]\1[0-9]{4}$
 
Share this answer
 
(?<vnumber>[a-zA-Z][a-zA-Z]\d\d[a-zA-Z]{1,2}\d\d\d\d)


Matches will be returned in the vnumber variable
 
Share this answer
 
v4
Comments
hitech_s 9-Sep-11 2:00am    
small correction plz dontmind

two alphabets is mandatory next 1 or 2 digits next 1 0r 2 alphabets next 1 to 4 digits
Mehdi Gholam 9-Sep-11 2:35am    
Fixed, the < > tags were giving trouble.
Member 12764429 6-Oct-16 1:06am    
I have already use the above regex but it is not working.Please help me
String reg1 = @"^[a-z]{2}[0-9]{2}[a-z]{1,2}[0-9]{4}$";
Regex regexVeh = new Regex(reg1, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
Match match = regexVeh.Match(txtVehNo.Text.Trim());
if (match.Success)
{
MessageBox.Show(match.Value);
}
else
{
MessageBox.Show("Enter Valid VechicleNo" + Environment.NewLine + "(Ex: TN46AM1234)", "Transport Details");
}


Above code will help you to validate the Vehicle numbers like TN23FT3456, TN54R3443
 
Share this answer
 
Comments
CHill60 29-Jul-15 9:28am    
Post was answered over 3 years ago. OP asked for the regex not the code, and does not mention c# at all. I also don't think ignore case is appropriate
Validators.pattern('[A-Z]{2}[ -][0-9]{1,2}(?: [A-Z])?(?: [A-Z]*)? [0-9]{4}')
 
Share this answer
 
Comments
OriginalGriff 1-Jun-22 3:14am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 11 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900