-
special characters
I am writing a parser. I have a character and want to know what it is (number, letter, special character etc).
Code:
char ch = 'a';
if (Character.isLetter(ch)) {
...
}
if (Character.isDigit(ch)) { // false
...
}
if (Character.isLowerCase(ch)) { // true
...
}
if (Character.isUpperCase(ch)) { // false
...
}
Special characters are %, &, /, (, ), = etc. Is there any method in Character class that I can use :confused:
Thanks in advance.
-
Not to my knowledge. You could create an Array, List or String containing the hex values of all the special characters that you want. Then just check to see if your characters is in the dataset.
I would personally just do it with a String and use the indexOf method. That's just me though.
-
hmm ...
cant we use ASCII character codes in such scenarios?