Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Strings
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BoXxI2004




PostPosted: Tue Mar 09, 2004 1:48 pm   Post subject: 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.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Mar 09, 2004 1:58 pm   Post subject: (No subject)

Hmmm...

code:
String initial = "hello how are you?";
initial.replaceAll("o", "silly");
BoXxI2004




PostPosted: Tue Mar 09, 2004 3:16 pm   Post subject: (No subject)

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




PostPosted: Tue Mar 09, 2004 5:15 pm   Post subject: (No subject)

bah, always with the long methods Rolling Eyes

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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: