Computer Science Canada Need help in replacing a words inside a string |
Author: | WooFerPPK [ Wed Mar 24, 2004 8:01 pm ] | ||
Post subject: | Need help in replacing a words inside a string | ||
i need to make a program that will find a word inside a sentence then replace that word with another word i type. i cannot fiqure out how to replace the word without deleting the string and just getting the word this is what i have so far
Thanks for your help (btw, i like what you guys did to the site 8) ) |
Author: | Tony [ Wed Mar 24, 2004 8:08 pm ] |
Post subject: | |
well you use indexOf to find where the string to be replaced is located. Then you construct a new string in this order everything to the left of index + replacement string + everything to the right of (index + length of string to replace) |