Can you show your code, relevant to your question, what your replacing loop really does?
How would you do this "by hand" without using a computer? Pretend you have a friend who has no idea how to do this- what steps would you tell him to do?
When you have those steps written out in English, you'll have an algorithm that should be pretty simple to convert to code.
What you suppose to do with three parameters ?
Three parameters? You mean the three arguments? I'm Not sure i understand the question.
Yes, three arguments.
If I'm correct, that is basically one is he sentence the other one is what you want to check which is exist or not and the last one is the replacement sentence/word.
In your code segment, since the next index is validating in each iteration I cannot see that leads to any endless loop.
Could you post the all three sentences that you used.
The problem is in your algorithm- you're checking the whole sentence each time, without taking words you've already changed into consideration.
Are you expecting us to come up with a different algorithm for you? Where's the fun in that?
I see two "easy" ways to do it. I'll give you a hint for each.
Hint: Why not operate on each word separately, instead of the entire sentence?
Hint: You want to replace all occurrences of a certain substring with another substring, right? Check out the String API for useful functions.
Thank you, I will see if I can get something to work by looking at it a word at time.
Please don't delete the original content in the forum next time. If you did so the thread become really mess, and useless for other members. Please don't do it next time.