[Solved] How can I check if a String contains X letters and Y numbers? [closed]

[ad_1]

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

[ad_2]

solved How can I check if a String contains X letters and Y numbers? [closed]