aspose file tools*
The moose likes Beginning Java and the fly likes how to differntiate special characters and normal characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to differntiate special characters and normal characters" Watch "how to differntiate special characters and normal characters" New topic
Author

how to differntiate special characters and normal characters

sandy bol
Greenhorn

Joined: Jul 16, 2008
Posts: 11

Hi All
i have a string object suppose
String s="abcdecf%ass$ASDFF"
so how could i replace the special character in the above string with 'X'

Please help out on this
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

Java doesn't have a definition for "special characters". So, you'll have to identify which of those characters you consider to be "special".
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
But Java does have a class called Character with all sorts of methods to identify different types of character.
sandy bol
Greenhorn

Joined: Jul 16, 2008
Posts: 11
is there anyway to tracing special characters by ASCII code
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

Again, you're the one who has to say what is "special" in your requirements.
B. Bent
Greenhorn

Joined: Jun 05, 2009
Posts: 5
All characters have ascii code (including "special"), so you could you use them if you like, but I'm not sure why.
Maybe you could put all yours "special" character in one array, and then compare every member of array with every character of your string.
Or maybe combined method isLetter() and isDigit() of Character class (if you want only letters and digits).
sandy bol
Greenhorn

Joined: Jul 16, 2008
Posts: 11
Thanks B.Bent
i succeeded in my task by using Character class
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to differntiate special characters and normal characters