Hello everyone here...
I need to build up a swing application related to vehicle registration and in which i want to do input the vehicle number of indian standard, like
Say for example if the user already entered a value like:
DL
then the textbox did not take the next input any other than a integer or one more char as.....
DL C
from here user can only enter a integer value............
So, in short what i want to do is to take the input only like that regex given by Alix
Based on the Wikipedia Specs
^[A-Z]{2}[ -][0-9]{1,2}(?: [A-Z])?(?: [A-Z]*)? [0-9]{4}$
//DL 01 C AA 1234
^[A-Z]{2}[ -]{0,1}[0-9]{2}[ -]{0,1}(?:[A-Z])[ -]{0,1}[A-Z]{1,2}[ -]{0,1}[0-9]{1,4}$
//MH 15 AA 1234
^[A-Z]{2}[ -]{0,1}[0-9]{2}[ -]{0,1}[A-Z]{1,2}[ -]{0,1}[0-9]{1,4}$
MVA 1234
^[A-Z]{3}[ -]{0,1}[0-9]{1,4}$
//MH 15 8008
^[A-Z]{2}[ -]{0,1}[0-9]{2}[ -]{0,1}[0-9]{1,4}$
with or without space :)
-(BOOL) validateVehicleRegNumber:(NSString *)strNumber { //Example MH14DA8904
NSString *validReg = @"[A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", validReg];
return [emailTest evaluateWithObject:strNumber];
}
If you are looking for number plate in substring then use the following regex
.*?([A-Za-z]{2})(\d{2})([A-Za-z]{2})(\d{4}).*?
^[A-Z]{2} [0-9]{2} [A-Z]{2} [0-9]{4}$
See http://en.wikipedia.org/wiki/Vehicle_registration_plates_of_India
Looks like the format is a bit more complex than stated in your question...