This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Saving A Clean String 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 "Saving A Clean String" Watch "Saving A Clean String" New topic
Author

Saving A Clean String

Jonathan Fleming
Greenhorn

Joined: Jul 18, 2003
Posts: 2
How can I go about making sure that no bad or special characters are entered into a string?
Basically I'd like the string to be of ascii characters only or those that can be used in an image filename on the web.
Thanks
Jonathan :^)
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
hi Jonathan,
If you're using java 1.4+, you can try

In English: "I'm going to describe a String: if my description matches this particular candidate String exactly, then return true, else false.
The description is this: I'd like any sequence of letters, numbers, or underscores, repeated one or more times. Then, I'd like a period. then, I'd like any sequence of letters, numbers, or underscores, repeated one or more times"
HTH,
M


Java Regular Expressions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Saving A Clean String
 
Similar Threads
maximum characters in string
Regex
How to write regular expression to skip a specific charaters in word
How to generate and check invalid SJIS characters?
logging byte[]