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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 804
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...)
 
jQuery in Action, 2nd edition
 
subject: Non-Alphanumeric Characters in a String
 
Similar Threads
Regex
anchor tag and passing a variable
String replaceAll method removes backslashes in replacement string
url sometimes we use / or \ difference
getting problem in converting the backward slash to forward slash