perl - Detect letter where number was expected -


how can detect , show error if put letter , program expects number?

a regexp match makes easy. searching character isn't numeral or arithmetic symbol:

if ( $input =~ /[^0-9+*/-]/ ) {   print "incorrect character detected!\n" } 

literally letter:

if ( $input =~ /[a-za-z]/ ) {   print "incorrect character detected!\n" } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -