Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String.replace to remove a character

 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. THANKS.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic