Alex Rivera | Logout

What is the best way to tell if a character is a letter or number in Java without using regexes?

Asked 2010-10-28T23:01:26.870
213

What is the best and/or easiest way to recognize if a string.charAt(index) is an A-z letter or a number in Java without using regular expressions? Thanks.

Edit
Report

1 Answer

12

I don't know about best, but this seems pretty simple to me:

Character.isDigit(str.charAt(index))
Character.isLetter(str.charAt(index))
answered 2010-10-28T23:07:23.427

Your Answer