This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to replace a string in a string with another string? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to replace a string in a string with another string?" Watch "how to replace a string in a string with another string?" New topic
Author

how to replace a string in a string with another string?

Sri Nivas
Ranch Hand

Joined: Apr 18, 2001
Posts: 58
The replace method for String object only replaces a char with another char.
I need a method which replaces a part of a string with another string?
What is the best method to do this?
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
Look at the replace() method that StringBuffers use. I think that will work for you, and it's very easy to convert from a String to a StringBuffer and back again.
Originally posted by Srini Madgula:
The replace method for String object only replaces a char with another char.
I need a method which replaces a part of a string with another string?
What is the best method to do this?


There's nothing more dangerous than a resourceful idiot. ---Dilbert
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to replace a string in a string with another string?