This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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.
 
Have you checked out Aspose?
 
subject: String.replace to remove a character
 
It's not a secret anymore!