You can simply work with regular expressions. Something like:
if(vehicleId.matches("^[A-Z]{3}\d{4}$"))
(Assuming the id contains three capital letters followed by four digits.)
This will return a boolean if vehicleId
, supposedly a variable holding the user’s input, is matched.
2
solved How can I check if a String contains X letters and Y numbers? [closed]