java - How to replace a substring without using replace() methods -


i trying convert text document shorthand, without using of replace() methods in java. 1 of strings converting "the" "&". problem is, not know substring of each word contains "the" string. how replace part of string without using replace() method?

ex: "their" become "&ir", "together" become "toge&r"

this have started with,

string = "the"; scanner wordscanner = new scanner(word);     if (wordscanner.contains(the)) {         = "&";     } 

i not sure how go replacement.

you try :

string word = "your string the"; word = stringutils.join(word.split("the"),"&"); scanner wordscanner = new scanner(word); 

Comments