
-----------------------------------
BoXxI2004
Tue Mar 09, 2004 1:48 pm

Strings
-----------------------------------
i am making a program where the user enters a sentance, a word to be replace and a new word to be replaced with. 
for ex : Hello , how are you 
 i want to replace the letter o with silly it would become

Hellsilly, hsillyw are ysillyu

u cant use the direct method where u use .replace... but i know the algoruthm where u pull the words apart.... but i am having trouble with sticking the new word in... meaning i dont know how to not include the letter .. and put in the new word.

-----------------------------------
wtd
Tue Mar 09, 2004 1:58 pm


-----------------------------------
Hmmm...

String initial = "hello how are you?";
initial.replaceAll("o", "silly");

-----------------------------------
BoXxI2004
Tue Mar 09, 2004 3:16 pm


-----------------------------------
u cant use the shortcut.. ie "replace"... u have to go about using the long method of using index og, and substrings.... how do u do that..

-----------------------------------
Tony
Tue Mar 09, 2004 5:15 pm


-----------------------------------
bah, always with the long methods :roll:

so you just run a forloops checking all the substrings the size of template to be replaced... if the substring matches the template, then replace it with replacement string
