wood burning stoves 2.0*
The moose likes Java in General and the fly likes Non-Alphanumeric Characters in a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Non-Alphanumeric Characters in a String" Watch "Non-Alphanumeric Characters in a String" New topic
Author

Non-Alphanumeric Characters in a String

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I understand if we have a non-alphanumeric character in a String, we have to put a backward slash in front of that character. For example, we have to put a backward slach in front of a "backward slash". Eg. we do \\ to put a backward slash in a String.

What about a dot (.) or a dash (-)? Do we have to do the same thing?
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Most punctuation does not need to be escaped. (That's what it's called when you put a backslash in front of a character.)

A few that do are the backslash itself (\\) and the quotation marks (\").


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Non-Alphanumeric Characters in a String