Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes How do i check for special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do i check for special characters " Watch "How do i check for special characters " New topic
Author

How do i check for special characters

Anil Verghese
Ranch Hand

Joined: Oct 11, 2006
Posts: 155
Hi,

How do i check whether a string has special characters or not


Anil
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38044
    
  22
More of a beginners' question.
What do you mean by special characters?
Suggest you split the String into a char[] array and use the methods of the Character class on the individual chars.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
The character-by-character approach will work.

An alternative would be to use a regular expression, via java.util.regex.Pattern. If you look up the API doc for Pattern, you will see that there are a wide variety of character classes on which you can match.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
 
subject: How do i check for special characters
 
Similar Threads
Passing the JSTL variable (with special characters) to JavaScript function?
Range of Special Character
HQL + LIKE + _
How to check whether the input string contains numbers,comma,colon
regex question