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 String.replace to remove a character 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 "String.replace to remove a character" Watch "String.replace to remove a character" New topic
Author

String.replace to remove a character

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
I know you can use String.replace to replace a character with a space but can you use this same method to remove the character?
I.E
-----------
String st = "I'm";
st = st.replace('\'','some character I dont know about');
System.out.println(st);
-------------
would print Im
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
sorry but i don't know if a empty char exist!
if you have to do this use a little loop like this:

------------------
Benjamin l´┐Żonard
www.evisor.com
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Cool. THANKS.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String.replace to remove a character
 
Similar Threads
character representation of a blank space
Using contains/equals/== with random characters?
How to remove '\0'
replacing space in file
string.replace limited to only one character.