I want to print an error message if a letter comes after the first two letters in the following expression.
EN545454545
CodePudding user response:
You can try using the tryParse
method of num
, if it fails parsing it returns null
which means it contained some illegal characters
String code = 'EN545454545';
if (num.tryParse(code.substring(2)) == null) {
// Handle error
}