在不使用正则表达式的情况下,判断字符是Java中的字母还是数字的最佳方法是什么? [英] What is the best way to tell if a character is a letter or number in Java without using regexes?
本文介绍了在不使用正则表达式的情况下,判断字符是Java中的字母还是数字的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在不使用正则表达式的情况下,识别string.charAt(index)是Java中的A-z字母还是数字的最佳和/或最简便的方法是什么?谢谢.
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.
推荐答案
Character.isDigit(string.charAt(index))
( JavaDoc )如果是字母,则返回true
Character.isDigit(string.charAt(index))
(JavaDoc) will return true if it's a digit
Character.isLetter(string.charAt(index))
(JavaDoc) will return true if it's a letter
这篇关于在不使用正则表达式的情况下,判断字符是Java中的字母还是数字的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文