This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes string.replace limited to only one character. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "string.replace limited to only one character." Watch "string.replace limited to only one character." New topic
Author

string.replace limited to only one character.

Steve Nix
Greenhorn

Joined: Jun 22, 2001
Posts: 1
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

Joined: Feb 26, 2001
Posts: 4442
    
    5

The StringBuffer class has methods that will let you do what you want. Check out the delete() method.

Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string.replace limited to only one character.
 
Similar Threads
String.replace to remove a character
String from JTextField
character representation of a blank space
replaceAll("+"," ")
Special Characters