File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string.replace limited to only one character.

 
Steve Nix
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to use string.replace or another method to remove the occurrence of more than one character. In other words, how could I remove the word "cat" from the following string:
myString = "That dog ate the neighbors cat!"
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The StringBuffer class has methods that will let you do what you want. Check out the delete() method.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic