Results 1 to 3 of 3
  1. #1
    ravian is offline Senior Member
    Join Date
    Nov 2007
    Posts
    115
    Rep Power
    0

    Default special characters

    I am writing a parser. I have a character and want to know what it is (number, letter, special character etc).

    Java 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.

  2. #2
    ShoeNinja's Avatar
    ShoeNinja is offline Senior Member
    Join Date
    Oct 2007
    Posts
    124
    Rep Power
    0

    Default

    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.

  3. #3
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default

    hmm ...
    cant we use ASCII character codes in such scenarios?

Similar Threads

  1. characters + strings
    By Gilgamesh in forum New To Java
    Replies: 3
    Last Post: 03-02-2008, 10:10 PM
  2. Replies: 1
    Last Post: 08-07-2007, 06:32 AM
  3. show special symbol using its Unicode character
    By christina in forum AWT / Swing
    Replies: 1
    Last Post: 07-25-2007, 10:21 AM
  4. Special characters in text fields
    By Felissa in forum Web Frameworks
    Replies: 0
    Last Post: 06-27-2007, 05:47 PM
  5. Getting all characters in a String
    By Alayna in forum New To Java
    Replies: 2
    Last Post: 05-20-2007, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •